Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
],
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -6924,6 +6925,7 @@
"MonitorNotificationRuleCreateRequestData",
"MonitorNotificationRuleData",
"MonitorNotificationRuleFilter",
"MonitorNotificationRuleFilterScope",
"MonitorNotificationRuleFilterTags",
"MonitorNotificationRuleListResponse",
"MonitorNotificationRuleRelationships",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-11-11T21:28:39.129Z
Loading