diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2b877f268d..92c61b23ac 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/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 2c383db88f..b28ad5ea1c 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -14123,6 +14123,13 @@ datadog\_api\_client.v2.model.monitor\_notification\_rule\_filter module :members: :show-inheritance: +datadog\_api\_client.v2.model.monitor\_notification\_rule\_filter\_scope module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_filter_scope + :members: + :show-inheritance: + datadog\_api\_client.v2.model.monitor\_notification\_rule\_filter\_tags module ------------------------------------------------------------------------------ diff --git a/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.py b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.py new file mode 100644 index 0000000000..21113bd5a4 --- /dev/null +++ b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.py @@ -0,0 +1,36 @@ +""" +Create a monitor notification rule with scope 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_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_scope import MonitorNotificationRuleFilterScope +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + +body = MonitorNotificationRuleCreateRequest( + data=MonitorNotificationRuleCreateRequestData( + attributes=MonitorNotificationRuleAttributes( + filter=MonitorNotificationRuleFilterScope( + scope="test:example-monitor", + ), + name="test rule", + 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_1446058210.py b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.py new file mode 100644 index 0000000000..f2530bf7d2 --- /dev/null +++ b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.py @@ -0,0 +1,40 @@ +""" +Update a monitor notification rule with scope 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_filter_scope import MonitorNotificationRuleFilterScope +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=MonitorNotificationRuleFilterScope( + scope="test:example-monitor", + ), + name="updated rule", + recipients=[ + "slack-test-channel", + ], + ), + 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 747f72f2f5..6bc951435a 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 @@ -19,6 +19,7 @@ ) 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 + from datadog_api_client.v2.model.monitor_notification_rule_filter_scope import MonitorNotificationRuleFilterScope class MonitorNotificationRuleAttributes(ModelNormal): @@ -62,14 +63,19 @@ def __init__( self_, name: str, conditional_recipients: Union[MonitorNotificationRuleConditionalRecipients, UnsetType] = unset, - filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, + filter: Union[ + MonitorNotificationRuleFilter, + MonitorNotificationRuleFilterTags, + MonitorNotificationRuleFilterScope, + 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. + :param conditional_recipients: Use conditional recipients to define different recipients for different situations. Cannot be used with ``recipients``. :type conditional_recipients: MonitorNotificationRuleConditionalRecipients, optional :param filter: Filter used to associate the notification rule with monitors. @@ -78,7 +84,7 @@ def __init__( :param name: The name of the monitor notification rule. :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 '@'. + :param recipients: 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``. :type recipients: [str], optional """ if conditional_recipients is not unset: 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 index c58a79bdff..acb5c3e052 100644 --- a/src/datadog_api_client/v2/model/monitor_notification_rule_condition.py +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_condition.py @@ -39,7 +39,7 @@ 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 '@'. + :param recipients: 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``. :type recipients: [str] :param scope: The scope to which the monitor applied. 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 index 88cf2d2b22..2e7c8f074c 100644 --- 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 @@ -50,12 +50,12 @@ def __init__( **kwargs, ): """ - 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``. :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 '@'. + :param fallback_recipients: 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``. :type fallback_recipients: [str], optional """ if fallback_recipients is not unset: diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py b/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py index 07b693934f..00a8079d4b 100644 --- a/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py @@ -15,8 +15,11 @@ def __init__(self, **kwargs): """ Filter used to associate the notification rule with monitors. - :param tags: A list of monitor tags. + :param tags: A list of tags (key:value pairs), which can be used to filter monitor notifications on monitor and group tags. :type tags: [str] + + :param scope: A scope composed of one or several key:value pairs, which can be used to filter monitor notifications on monitor and group tags. + :type scope: str """ super().__init__(kwargs) @@ -30,9 +33,13 @@ def _composed_schemas(_): # classes don't exist yet because their module has not finished # loading from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags + from datadog_api_client.v2.model.monitor_notification_rule_filter_scope import ( + MonitorNotificationRuleFilterScope, + ) return { "oneOf": [ MonitorNotificationRuleFilterTags, + MonitorNotificationRuleFilterScope, ], } diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_filter_scope.py b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_scope.py new file mode 100644 index 0000000000..6111968c86 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_scope.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class MonitorNotificationRuleFilterScope(ModelNormal): + validations = { + "scope": { + "max_length": 3000, + "min_length": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + return { + "scope": (str,), + } + + attribute_map = { + "scope": "scope", + } + + def __init__(self_, scope: str, **kwargs): + """ + Filter monitor notifications. A monitor notification must match the scope. + + :param scope: A scope composed of one or several key:value pairs, which can be used to filter monitor notifications on monitor and group tags. + :type scope: str + """ + super().__init__(kwargs) + + self_.scope = scope diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py index ee5a260331..401501fbfc 100644 --- a/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py @@ -35,9 +35,9 @@ def openapi_types(_): def __init__(self_, tags: List[str], **kwargs): """ - Filter monitors by tags. Monitors must match all tags. + Filter monitor notifications by tags. A monitor notification must match all tags. - :param tags: A list of monitor tags. + :param tags: A list of tags (key:value pairs), which can be used to filter monitor notifications on monitor and group tags. :type tags: [str] """ super().__init__(kwargs) 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 097c356d59..4534829774 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 @@ -20,6 +20,7 @@ ) 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 + from datadog_api_client.v2.model.monitor_notification_rule_filter_scope import MonitorNotificationRuleFilterScope class MonitorNotificationRuleResponseAttributes(ModelNormal): @@ -63,7 +64,12 @@ def __init__( self_, conditional_recipients: Union[MonitorNotificationRuleConditionalRecipients, UnsetType] = unset, created: Union[datetime, UnsetType] = unset, - filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, + filter: Union[ + MonitorNotificationRuleFilter, + MonitorNotificationRuleFilterTags, + MonitorNotificationRuleFilterScope, + UnsetType, + ] = unset, modified: Union[datetime, UnsetType] = unset, name: Union[str, UnsetType] = unset, recipients: Union[List[str], UnsetType] = unset, @@ -72,7 +78,7 @@ def __init__( """ Attributes of the monitor notification rule. - :param conditional_recipients: Use conditional recipients to define different recipients for different situations. + :param conditional_recipients: Use conditional recipients to define different recipients for different situations. Cannot be used with ``recipients``. :type conditional_recipients: MonitorNotificationRuleConditionalRecipients, optional :param created: Creation time of the monitor notification rule. @@ -87,7 +93,7 @@ def __init__( :param name: The name of the monitor notification rule. :type name: str, optional - :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. + :param recipients: 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``. :type recipients: [str], optional """ if conditional_recipients is not unset: diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 94b77ad334..8d015c5ba1 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2656,6 +2656,7 @@ ) from datadog_api_client.v2.model.monitor_notification_rule_data import MonitorNotificationRuleData from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter +from datadog_api_client.v2.model.monitor_notification_rule_filter_scope import MonitorNotificationRuleFilterScope from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags from datadog_api_client.v2.model.monitor_notification_rule_list_response import MonitorNotificationRuleListResponse from datadog_api_client.v2.model.monitor_notification_rule_relationships import MonitorNotificationRuleRelationships @@ -6924,6 +6925,7 @@ "MonitorNotificationRuleCreateRequestData", "MonitorNotificationRuleData", "MonitorNotificationRuleFilter", + "MonitorNotificationRuleFilterScope", "MonitorNotificationRuleFilterTags", "MonitorNotificationRuleListResponse", "MonitorNotificationRuleRelationships", diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_scope_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_scope_returns_ok_response.frozen new file mode 100644 index 0000000000..94917c9e8b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_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/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_scope_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_scope_returns_ok_response.yaml new file mode 100644 index 0000000000..5d7ccf12ac --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_with_scope_returns_ok_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{"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: + 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}}]} + + ' + 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/bbea2907-c191-48d0-9e0f-1ec5881ee37c + 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_scope_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_scope_returns_ok_response.frozen new file mode 100644 index 0000000000..ab91f3c3d0 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_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/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_scope_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_scope_returns_ok_response.yaml new file mode 100644 index 0000000000..591e9e90e6 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_with_scope_returns_ok_response.yaml @@ -0,0 +1,64 @@ +interactions: +- request: + body: '{"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: + 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}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"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: + 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}}]} + + ' + 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/827442a0-5d3e-408c-a930-7ac44775fff1 + 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 346a646f83..e84062637c 100644 --- a/tests/v2/features/monitors.feature +++ b/tests/v2/features/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