diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 17509b5688..a0d1812167 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29565,6 +29565,8 @@ components: additionalProperties: false description: Attributes of the monitor notification rule. properties: + conditional_recipients: + $ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients' filter: $ref: '#/components/schemas/MonitorNotificationRuleFilter' name: @@ -29573,8 +29575,36 @@ components: $ref: '#/components/schemas/MonitorNotificationRuleRecipients' required: - name + type: object + MonitorNotificationRuleCondition: + description: Conditions for `conditional_recipients`. + properties: + recipients: + $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + scope: + $ref: '#/components/schemas/MonitorNotificationRuleScope' + required: + - scope - recipients type: object + MonitorNotificationRuleConditionalRecipients: + description: Use conditional recipients to define different recipients for different + situations. + properties: + conditions: + description: Conditions of the notification rule. + items: + $ref: '#/components/schemas/MonitorNotificationRuleCondition' + maxItems: 10 + minItems: 1 + type: array + fallback_recipients: + $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + description: If none of the `conditions` applied, `fallback_recipients` + will get notified. + required: + - conditions + type: object MonitorNotificationRuleCreateRequest: description: Request for creating a monitor notification rule. properties: @@ -29714,6 +29744,8 @@ components: additionalProperties: {} description: Attributes of the monitor notification rule. properties: + conditional_recipients: + $ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients' created: description: Creation time of the monitor notification rule. example: 2020-01-02 03:04:00+00:00 @@ -29735,6 +29767,12 @@ 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/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index b67656f61b..e7d1e36680 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -12835,6 +12835,20 @@ datadog\_api\_client.v2.model.monitor\_notification\_rule\_attributes module :members: :show-inheritance: +datadog\_api\_client.v2.model.monitor\_notification\_rule\_condition module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_condition + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_conditional\_recipients module +----------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients + :members: + :show-inheritance: + datadog\_api\_client.v2.model.monitor\_notification\_rule\_create\_request module --------------------------------------------------------------------------------- diff --git a/examples/v2/monitors/CreateMonitorNotificationRule_1181818787.py b/examples/v2/monitors/CreateMonitorNotificationRule_1181818787.py new file mode 100644 index 0000000000..77475b01fc --- /dev/null +++ b/examples/v2/monitors/CreateMonitorNotificationRule_1181818787.py @@ -0,0 +1,49 @@ +""" +Create a monitor notification rule with conditional recipients returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi +from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition +from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, +) +from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest +from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import ( + MonitorNotificationRuleCreateRequestData, +) +from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + +body = MonitorNotificationRuleCreateRequest( + data=MonitorNotificationRuleCreateRequestData( + attributes=MonitorNotificationRuleAttributes( + filter=MonitorNotificationRuleFilterTags( + tags=[ + "test:example-monitor", + ], + ), + name="test rule", + conditional_recipients=MonitorNotificationRuleConditionalRecipients( + conditions=[ + MonitorNotificationRuleCondition( + scope="transition_type:is_alert", + recipients=[ + "slack-test-channel", + "jira-test", + ], + ), + ], + ), + ), + type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.create_monitor_notification_rule(body=body) + + print(response) diff --git a/examples/v2/monitors/UpdateMonitorNotificationRule_1400905713.py b/examples/v2/monitors/UpdateMonitorNotificationRule_1400905713.py new file mode 100644 index 0000000000..90f1d2a319 --- /dev/null +++ b/examples/v2/monitors/UpdateMonitorNotificationRule_1400905713.py @@ -0,0 +1,55 @@ +""" +Update a monitor notification rule with conditional_recipients returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi +from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition +from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, +) +from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType +from datadog_api_client.v2.model.monitor_notification_rule_update_request import MonitorNotificationRuleUpdateRequest +from datadog_api_client.v2.model.monitor_notification_rule_update_request_data import ( + MonitorNotificationRuleUpdateRequestData, +) + +# there is a valid "monitor_notification_rule" in the system +MONITOR_NOTIFICATION_RULE_DATA_ID = environ["MONITOR_NOTIFICATION_RULE_DATA_ID"] + +body = MonitorNotificationRuleUpdateRequest( + data=MonitorNotificationRuleUpdateRequestData( + attributes=MonitorNotificationRuleAttributes( + filter=MonitorNotificationRuleFilterTags( + tags=[ + "test:example-monitor", + "host:abc", + ], + ), + name="updated rule", + conditional_recipients=MonitorNotificationRuleConditionalRecipients( + conditions=[ + MonitorNotificationRuleCondition( + scope="transition_type:is_alert", + recipients=[ + "slack-test-channel", + "jira-test", + ], + ), + ], + ), + ), + id=MONITOR_NOTIFICATION_RULE_DATA_ID, + type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.update_monitor_notification_rule(rule_id=MONITOR_NOTIFICATION_RULE_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py b/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py index 23de90d18c..747f72f2f5 100644 --- a/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py @@ -14,6 +14,9 @@ if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, + ) from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags @@ -36,15 +39,20 @@ def additional_properties_type(_): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, + ) from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter return { + "conditional_recipients": (MonitorNotificationRuleConditionalRecipients,), "filter": (MonitorNotificationRuleFilter,), "name": (str,), "recipients": ([str],), } attribute_map = { + "conditional_recipients": "conditional_recipients", "filter": "filter", "name": "name", "recipients": "recipients", @@ -53,13 +61,17 @@ def openapi_types(_): def __init__( self_, name: str, - recipients: List[str], + conditional_recipients: Union[MonitorNotificationRuleConditionalRecipients, UnsetType] = unset, filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, + recipients: Union[List[str], UnsetType] = unset, **kwargs, ): """ Attributes of the monitor notification rule. + :param conditional_recipients: Use conditional recipients to define different recipients for different situations. + :type conditional_recipients: MonitorNotificationRuleConditionalRecipients, optional + :param filter: Filter used to associate the notification rule with monitors. :type filter: MonitorNotificationRuleFilter, optional @@ -67,11 +79,14 @@ def __init__( :type name: str :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. - :type recipients: [str] + :type recipients: [str], optional """ + if conditional_recipients is not unset: + kwargs["conditional_recipients"] = conditional_recipients if filter is not unset: kwargs["filter"] = filter + if recipients is not unset: + kwargs["recipients"] = recipients super().__init__(kwargs) self_.name = name - self_.recipients = recipients diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_condition.py b/src/datadog_api_client/v2/model/monitor_notification_rule_condition.py new file mode 100644 index 0000000000..c58a79bdff --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_condition.py @@ -0,0 +1,51 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class MonitorNotificationRuleCondition(ModelNormal): + validations = { + "recipients": { + "max_items": 20, + "min_items": 1, + }, + "scope": { + "max_length": 3000, + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "recipients": ([str],), + "scope": (str,), + } + + attribute_map = { + "recipients": "recipients", + "scope": "scope", + } + + def __init__(self_, recipients: List[str], scope: str, **kwargs): + """ + Conditions for ``conditional_recipients``. + + :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. + :type recipients: [str] + + :param scope: The scope to which the monitor applied. + :type scope: str + """ + super().__init__(kwargs) + + self_.recipients = recipients + self_.scope = scope diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_conditional_recipients.py b/src/datadog_api_client/v2/model/monitor_notification_rule_conditional_recipients.py new file mode 100644 index 0000000000..88cf2d2b22 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_conditional_recipients.py @@ -0,0 +1,65 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition + + +class MonitorNotificationRuleConditionalRecipients(ModelNormal): + validations = { + "conditions": { + "max_items": 10, + "min_items": 1, + }, + "fallback_recipients": { + "max_items": 20, + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition + + return { + "conditions": ([MonitorNotificationRuleCondition],), + "fallback_recipients": ([str],), + } + + attribute_map = { + "conditions": "conditions", + "fallback_recipients": "fallback_recipients", + } + + def __init__( + self_, + conditions: List[MonitorNotificationRuleCondition], + fallback_recipients: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + Use conditional recipients to define different recipients for different situations. + + :param conditions: Conditions of the notification rule. + :type conditions: [MonitorNotificationRuleCondition] + + :param fallback_recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. + :type fallback_recipients: [str], optional + """ + if fallback_recipients is not unset: + kwargs["fallback_recipients"] = fallback_recipients + super().__init__(kwargs) + + self_.conditions = conditions diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py b/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py index 298ca6ce2f..097c356d59 100644 --- a/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py @@ -15,6 +15,9 @@ if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, + ) from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags @@ -33,9 +36,13 @@ class MonitorNotificationRuleResponseAttributes(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, + ) from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter return { + "conditional_recipients": (MonitorNotificationRuleConditionalRecipients,), "created": (datetime,), "filter": (MonitorNotificationRuleFilter,), "modified": (datetime,), @@ -44,6 +51,7 @@ def openapi_types(_): } attribute_map = { + "conditional_recipients": "conditional_recipients", "created": "created", "filter": "filter", "modified": "modified", @@ -53,6 +61,7 @@ def openapi_types(_): def __init__( self_, + conditional_recipients: Union[MonitorNotificationRuleConditionalRecipients, UnsetType] = unset, created: Union[datetime, UnsetType] = unset, filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, modified: Union[datetime, UnsetType] = unset, @@ -63,6 +72,9 @@ def __init__( """ Attributes of the monitor notification rule. + :param conditional_recipients: Use conditional recipients to define different recipients for different situations. + :type conditional_recipients: MonitorNotificationRuleConditionalRecipients, optional + :param created: Creation time of the monitor notification rule. :type created: datetime, optional @@ -78,6 +90,8 @@ def __init__( :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. :type recipients: [str], optional """ + if conditional_recipients is not unset: + kwargs["conditional_recipients"] = conditional_recipients if created is not unset: kwargs["created"] = created if filter is not unset: diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index a5ab1a9ae4..525d7e1a29 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2372,6 +2372,10 @@ ) from datadog_api_client.v2.model.monitor_downtime_match_response_data import MonitorDowntimeMatchResponseData from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition +from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import ( + MonitorNotificationRuleConditionalRecipients, +) from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import ( MonitorNotificationRuleCreateRequestData, @@ -6246,6 +6250,8 @@ "MonitorDowntimeMatchResponseAttributes", "MonitorDowntimeMatchResponseData", "MonitorNotificationRuleAttributes", + "MonitorNotificationRuleCondition", + "MonitorNotificationRuleConditionalRecipients", "MonitorNotificationRuleCreateRequest", "MonitorNotificationRuleCreateRequestData", "MonitorNotificationRuleData", diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen new file mode 100644 index 0000000000..da684d32eb --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-09-26T01:50:59.027Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml new file mode 100644 index 0000000000..ff89ce7e7b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{"data":{"attributes":{"conditional_recipients":{"conditions":[{"recipients":["slack-test-channel","jira-test"],"scope":"transition_type:is_alert"}]},"filter":{"tags":["test:test-create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851459"]},"name":"test + rule"},"type":"monitor-notification-rule"}}' + 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":{"name":"test + rule","filter":{"tags":["test:test-create_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851459"]},"created_at":"2025-09-26T01:51:00.132009+00:00","conditional_recipients":{"conditions":[{"recipients":["slack-test-channel","jira-test"],"scope":"transition_type:is_alert"}]},"modified_at":"1970-01-01T00:00:00+00:00"},"id":"707b82d7-6898-4b20-a577-64f76881fe89","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"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/707b82d7-6898-4b20-a577-64f76881fe89 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen new file mode 100644 index 0000000000..8543967b2b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-09-26T01:51:00.504Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml new file mode 100644 index 0000000000..95a350fcd4 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response.yaml @@ -0,0 +1,64 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851460"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + 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":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851460"]},"created_at":"2025-09-26T01:51:00.665373+00:00","name":"test + rule","recipients":["slack-monitor-app"],"modified_at":"1970-01-01T00:00:00+00:00"},"id":"954d2f74-ec41-4f7b-9f63-7146075f3537","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"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"conditional_recipients":{"conditions":[{"recipients":["slack-test-channel","jira-test"],"scope":"transition_type:is_alert"}]},"filter":{"tags":["test:test-update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851460","host:abc"]},"name":"updated + rule"},"id":"954d2f74-ec41-4f7b-9f63-7146075f3537","type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/954d2f74-ec41-4f7b-9f63-7146075f3537 + response: + body: + string: '{"data":{"type":"monitor-notification-rule","id":"954d2f74-ec41-4f7b-9f63-7146075f3537","attributes":{"filter":{"tags":["test:test-update_a_monitor_notification_rule_with_conditional_recipients_returns_ok_response-1758851460","host:abc"]},"modified_at":"2025-09-26T01:51:00.876883+00:00","conditional_recipients":{"conditions":[{"scope":"transition_type:is_alert","recipients":["slack-test-channel","jira-test"]}]},"name":"updated + rule","created_at":"2025-09-26T01:51:00.665373+00:00"},"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"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/954d2f74-ec41-4f7b-9f63-7146075f3537 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/monitors.feature b/tests/v2/features/monitors.feature index d49f00dd04..3fd3138f9f 100644 --- a/tests/v2/features/monitors.feature +++ b/tests/v2/features/monitors.feature @@ -44,6 +44,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 conditional recipients returns "OK" response + Given new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}"]}, "name": "test rule", "conditional_recipients": {"conditions": [{"scope": "transition_type:is_alert", "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 @@ -255,6 +263,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 conditional_recipients 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": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "updated rule", "conditional_recipients": {"conditions": [{"scope": "transition_type:is_alert", "recipients": ["slack-test-channel", "jira-test"]}]}}, "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