Skip to content
Open
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
15 changes: 15 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83298,6 +83298,8 @@ components:
$ref: "#/components/schemas/MonitorNotificationRuleName"
recipients:
$ref: "#/components/schemas/MonitorNotificationRuleRecipients"
rule_options:
$ref: "#/components/schemas/MonitorNotificationRuleOptions"
required: [name]
type: object
MonitorNotificationRuleBundleConfig:
Expand Down Expand Up @@ -83438,6 +83440,17 @@ components:
maxLength: 1000
minLength: 1
type: string
MonitorNotificationRuleOptions:
description: Additional options for the monitor notification rule.
properties:
is_threaded:
description: |-
Whether notifications from this rule are threaded. When `true`, follow-up notifications for the same monitor alert are posted in Slack as replies to the first notification.
Cannot be `true` when `bundle_config` is set.
example: true
type: boolean
required: [is_threaded]
type: object
MonitorNotificationRuleRecipients:
description: |-
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`.
Expand Down Expand Up @@ -83515,6 +83528,8 @@ components:
$ref: "#/components/schemas/MonitorNotificationRuleName"
recipients:
$ref: "#/components/schemas/MonitorNotificationRuleRecipients"
rule_options:
$ref: "#/components/schemas/MonitorNotificationRuleOptions"
type: object
MonitorNotificationRuleResponseIncludedItem:
description: An object related to a monitor notification rule.
Expand Down
43 changes: 43 additions & 0 deletions examples/v2/monitors/CreateMonitorNotificationRule_292428701.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Create a monitor notification rule with rule options 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_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_options import MonitorNotificationRuleOptions
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",
recipients=[
"slack-test-channel",
],
rule_options=MonitorNotificationRuleOptions(
is_threaded=True,
),
),
type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor_notification_rule(body=body)

print(response)
47 changes: 47 additions & 0 deletions examples/v2/monitors/UpdateMonitorNotificationRule_365435820.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Update a monitor notification rule with rule options 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_tags import MonitorNotificationRuleFilterTags
from datadog_api_client.v2.model.monitor_notification_rule_options import MonitorNotificationRuleOptions
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",
],
),
name="updated rule",
recipients=[
"slack-test-channel",
],
rule_options=MonitorNotificationRuleOptions(
is_threaded=False,
),
),
id=MONITOR_NOTIFICATION_RULE_DATA_ID,
type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
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 @@
MonitorNotificationRuleConditionalRecipients,
)
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
from datadog_api_client.v2.model.monitor_notification_rule_options import MonitorNotificationRuleOptions
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

Expand Down Expand Up @@ -48,13 +49,15 @@ def openapi_types(_):
MonitorNotificationRuleConditionalRecipients,
)
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
from datadog_api_client.v2.model.monitor_notification_rule_options import MonitorNotificationRuleOptions

return {
"bundle_config": (MonitorNotificationRuleBundleConfig,),
"conditional_recipients": (MonitorNotificationRuleConditionalRecipients,),
"filter": (MonitorNotificationRuleFilter,),
"name": (str,),
"recipients": ([str],),
"rule_options": (MonitorNotificationRuleOptions,),
}

attribute_map = {
Expand All @@ -63,6 +66,7 @@ def openapi_types(_):
"filter": "filter",
"name": "name",
"recipients": "recipients",
"rule_options": "rule_options",
}

def __init__(
Expand All @@ -77,6 +81,7 @@ def __init__(
UnsetType,
] = unset,
recipients: Union[List[str], UnsetType] = unset,
rule_options: Union[MonitorNotificationRuleOptions, UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -97,6 +102,9 @@ def __init__(

: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

:param rule_options: Additional options for the monitor notification rule.
:type rule_options: MonitorNotificationRuleOptions, optional
"""
if bundle_config is not unset:
kwargs["bundle_config"] = bundle_config
Expand All @@ -106,6 +114,8 @@ def __init__(
kwargs["filter"] = filter
if recipients is not unset:
kwargs["recipients"] = recipients
if rule_options is not unset:
kwargs["rule_options"] = rule_options
super().__init__(kwargs)

self_.name = name
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 MonitorNotificationRuleOptions(ModelNormal):
@cached_property
def openapi_types(_):
return {
"is_threaded": (bool,),
}

attribute_map = {
"is_threaded": "is_threaded",
}

def __init__(self_, is_threaded: bool, **kwargs):
"""
Additional options for the monitor notification rule.

:param is_threaded: Whether notifications from this rule are threaded. When ``true`` , follow-up notifications for the same monitor alert are posted in Slack as replies to the first notification.
Cannot be ``true`` when ``bundle_config`` is set.
:type is_threaded: bool
"""
super().__init__(kwargs)

self_.is_threaded = is_threaded
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
MonitorNotificationRuleConditionalRecipients,
)
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
from datadog_api_client.v2.model.monitor_notification_rule_options import MonitorNotificationRuleOptions
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

Expand All @@ -45,6 +46,7 @@ def openapi_types(_):
MonitorNotificationRuleConditionalRecipients,
)
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
from datadog_api_client.v2.model.monitor_notification_rule_options import MonitorNotificationRuleOptions

return {
"bundle_config": (MonitorNotificationRuleBundleConfig,),
Expand All @@ -54,6 +56,7 @@ def openapi_types(_):
"modified": (datetime,),
"name": (str,),
"recipients": ([str],),
"rule_options": (MonitorNotificationRuleOptions,),
}

attribute_map = {
Expand All @@ -64,6 +67,7 @@ def openapi_types(_):
"modified": "modified",
"name": "name",
"recipients": "recipients",
"rule_options": "rule_options",
}

def __init__(
Expand All @@ -80,6 +84,7 @@ def __init__(
modified: Union[datetime, UnsetType] = unset,
name: Union[str, UnsetType] = unset,
recipients: Union[List[str], UnsetType] = unset,
rule_options: Union[MonitorNotificationRuleOptions, UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -106,6 +111,9 @@ def __init__(

: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

:param rule_options: Additional options for the monitor notification rule.
:type rule_options: MonitorNotificationRuleOptions, optional
"""
if bundle_config is not unset:
kwargs["bundle_config"] = bundle_config
Expand All @@ -121,4 +129,6 @@ def __init__(
kwargs["name"] = name
if recipients is not unset:
kwargs["recipients"] = recipients
if rule_options is not unset:
kwargs["rule_options"] = rule_options
super().__init__(kwargs)
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 @@ -6720,6 +6720,7 @@
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_options import MonitorNotificationRuleOptions
from datadog_api_client.v2.model.monitor_notification_rule_relationships import MonitorNotificationRuleRelationships
from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by import (
MonitorNotificationRuleRelationshipsCreatedBy,
Expand Down Expand Up @@ -17949,6 +17950,7 @@
"MonitorNotificationRuleFilterScope",
"MonitorNotificationRuleFilterTags",
"MonitorNotificationRuleListResponse",
"MonitorNotificationRuleOptions",
"MonitorNotificationRuleRelationships",
"MonitorNotificationRuleRelationshipsCreatedBy",
"MonitorNotificationRuleRelationshipsCreatedByData",
Expand Down
14 changes: 14 additions & 0 deletions tests/generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8407,6 +8407,13 @@
"scenario": "Create a monitor notification rule with conditional recipients returns \"OK\" response",
"version": "v2"
},
{
"feature": "Monitors",
"feature_file": "../../v2/features/monitors.feature",
"file": "v2/monitors/create-a-monitor-notification-rule-with-rule-options-returns-ok-response.json",
"scenario": "Create a monitor notification rule with rule options returns \"OK\" response",
"version": "v2"
},
{
"feature": "Monitors",
"feature_file": "../../v2/features/monitors.feature",
Expand Down Expand Up @@ -8589,6 +8596,13 @@
"scenario": "Update a monitor notification rule with conditional_recipients returns \"OK\" response",
"version": "v2"
},
{
"feature": "Monitors",
"feature_file": "../../v2/features/monitors.feature",
"file": "v2/monitors/update-a-monitor-notification-rule-with-rule-options-returns-ok-response.json",
"scenario": "Update a monitor notification rule with rule options returns \"OK\" response",
"version": "v2"
},
{
"feature": "Monitors",
"feature_file": "../../v2/features/monitors.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"api": "Monitors",
"expected_status": 200,
"feature": "Monitors",
"id": "v2/Monitors/Create a monitor notification rule with rule options returns \"OK\" response",
"operation_id": "CreateMonitorNotificationRule",
"request": {
"body": {
"schema": {
"format": null,
"ref": "MonitorNotificationRuleCreateRequest",
"type": "object"
},
"source": "inline",
"value": {
"data": {
"attributes": {
"filter": {
"tags": [
"test:{{ unique_lower }}"
]
},
"name": "test rule",
"recipients": [
"slack-test-channel"
],
"rule_options": {
"is_threaded": true
}
},
"type": "monitor-notification-rule"
}
}
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/monitor/notification_rule"
},
"scenario": "Create a monitor notification rule with rule options returns \"OK\" response",
"schema_version": 1,
"version": "v2"
}
Loading
Loading