Skip to content

Commit d4bf5ca

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2c49d12 of spec repo
1 parent cbc06b7 commit d4bf5ca

14 files changed

+435
-3
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29063,6 +29063,8 @@ components:
2906329063
additionalProperties: false
2906429064
description: Attributes of the monitor notification rule.
2906529065
properties:
29066+
conditional_recipients:
29067+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2906629068
filter:
2906729069
$ref: '#/components/schemas/MonitorNotificationRuleFilter'
2906829070
name:
@@ -29071,8 +29073,36 @@ components:
2907129073
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
2907229074
required:
2907329075
- name
29076+
type: object
29077+
MonitorNotificationRuleCondition:
29078+
description: Conditions for `conditional_recipients`.
29079+
properties:
29080+
recipients:
29081+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29082+
scope:
29083+
$ref: '#/components/schemas/MonitorNotificationRuleScope'
29084+
required:
29085+
- scope
2907429086
- recipients
2907529087
type: object
29088+
MonitorNotificationRuleConditionalRecipients:
29089+
description: Use conditional recipients to define different recipients for different
29090+
situations.
29091+
properties:
29092+
conditions:
29093+
description: Conditions of the notification rule.
29094+
items:
29095+
$ref: '#/components/schemas/MonitorNotificationRuleCondition'
29096+
maxItems: 10
29097+
minItems: 1
29098+
type: array
29099+
fallback_recipients:
29100+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29101+
description: If none of the `conditions` applied, `fallback_recipients`
29102+
will get notified.
29103+
required:
29104+
- conditions
29105+
type: object
2907629106
MonitorNotificationRuleCreateRequest:
2907729107
description: Request for creating a monitor notification rule.
2907829108
properties:
@@ -29212,6 +29242,8 @@ components:
2921229242
additionalProperties: {}
2921329243
description: Attributes of the monitor notification rule.
2921429244
properties:
29245+
conditional_recipients:
29246+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2921529247
created:
2921629248
description: Creation time of the monitor notification rule.
2921729249
example: 2020-01-02 03:04:00+00:00
@@ -29233,6 +29265,12 @@ components:
2923329265
description: An object related to a monitor notification rule.
2923429266
oneOf:
2923529267
- $ref: '#/components/schemas/User'
29268+
MonitorNotificationRuleScope:
29269+
description: The scope to which the monitor applied.
29270+
example: transition_type:alert
29271+
maxLength: 3000
29272+
minLength: 1
29273+
type: string
2923629274
MonitorNotificationRuleUpdateRequest:
2923729275
description: Request for updating a monitor notification rule.
2923829276
properties:

docs/datadog_api_client.v2.model.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12618,6 +12618,20 @@ datadog\_api\_client.v2.model.monitor\_notification\_rule\_attributes module
1261812618
:members:
1261912619
:show-inheritance:
1262012620

12621+
datadog\_api\_client.v2.model.monitor\_notification\_rule\_condition module
12622+
---------------------------------------------------------------------------
12623+
12624+
.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_condition
12625+
:members:
12626+
:show-inheritance:
12627+
12628+
datadog\_api\_client.v2.model.monitor\_notification\_rule\_conditional\_recipients module
12629+
-----------------------------------------------------------------------------------------
12630+
12631+
.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients
12632+
:members:
12633+
:show-inheritance:
12634+
1262112635
datadog\_api\_client.v2.model.monitor\_notification\_rule\_create\_request module
1262212636
---------------------------------------------------------------------------------
1262312637

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Create a monitor notification rule with conditional recipients returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.monitors_api import MonitorsApi
7+
from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes
8+
from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition
9+
from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import (
10+
MonitorNotificationRuleConditionalRecipients,
11+
)
12+
from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest
13+
from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import (
14+
MonitorNotificationRuleCreateRequestData,
15+
)
16+
from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags
17+
from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType
18+
19+
body = MonitorNotificationRuleCreateRequest(
20+
data=MonitorNotificationRuleCreateRequestData(
21+
attributes=MonitorNotificationRuleAttributes(
22+
filter=MonitorNotificationRuleFilterTags(
23+
tags=[
24+
"test:example-monitor",
25+
],
26+
),
27+
name="test rule",
28+
conditional_recipients=MonitorNotificationRuleConditionalRecipients(
29+
conditions=[
30+
MonitorNotificationRuleCondition(
31+
scope="transition_type:is_alert",
32+
recipients=[
33+
"slack-test-channel",
34+
"jira-test",
35+
],
36+
),
37+
],
38+
),
39+
),
40+
type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE,
41+
),
42+
)
43+
44+
configuration = Configuration()
45+
with ApiClient(configuration) as api_client:
46+
api_instance = MonitorsApi(api_client)
47+
response = api_instance.create_monitor_notification_rule(body=body)
48+
49+
print(response)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Update a monitor notification rule with conditional_recipients returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.monitors_api import MonitorsApi
8+
from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes
9+
from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition
10+
from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import (
11+
MonitorNotificationRuleConditionalRecipients,
12+
)
13+
from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags
14+
from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType
15+
from datadog_api_client.v2.model.monitor_notification_rule_update_request import MonitorNotificationRuleUpdateRequest
16+
from datadog_api_client.v2.model.monitor_notification_rule_update_request_data import (
17+
MonitorNotificationRuleUpdateRequestData,
18+
)
19+
20+
# there is a valid "monitor_notification_rule" in the system
21+
MONITOR_NOTIFICATION_RULE_DATA_ID = environ["MONITOR_NOTIFICATION_RULE_DATA_ID"]
22+
23+
body = MonitorNotificationRuleUpdateRequest(
24+
data=MonitorNotificationRuleUpdateRequestData(
25+
attributes=MonitorNotificationRuleAttributes(
26+
filter=MonitorNotificationRuleFilterTags(
27+
tags=[
28+
"test:example-monitor",
29+
"host:abc",
30+
],
31+
),
32+
name="updated rule",
33+
conditional_recipients=MonitorNotificationRuleConditionalRecipients(
34+
conditions=[
35+
MonitorNotificationRuleCondition(
36+
scope="transition_type:is_alert",
37+
recipients=[
38+
"slack-test-channel",
39+
"jira-test",
40+
],
41+
),
42+
],
43+
),
44+
),
45+
id=MONITOR_NOTIFICATION_RULE_DATA_ID,
46+
type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE,
47+
),
48+
)
49+
50+
configuration = Configuration()
51+
with ApiClient(configuration) as api_client:
52+
api_instance = MonitorsApi(api_client)
53+
response = api_instance.update_monitor_notification_rule(rule_id=MONITOR_NOTIFICATION_RULE_DATA_ID, body=body)
54+
55+
print(response)

src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import (
18+
MonitorNotificationRuleConditionalRecipients,
19+
)
1720
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
1821
from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags
1922

@@ -36,15 +39,20 @@ def additional_properties_type(_):
3639

3740
@cached_property
3841
def openapi_types(_):
42+
from datadog_api_client.v2.model.monitor_notification_rule_conditional_recipients import (
43+
MonitorNotificationRuleConditionalRecipients,
44+
)
3945
from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter
4046

4147
return {
48+
"conditional_recipients": (MonitorNotificationRuleConditionalRecipients,),
4249
"filter": (MonitorNotificationRuleFilter,),
4350
"name": (str,),
4451
"recipients": ([str],),
4552
}
4653

4754
attribute_map = {
55+
"conditional_recipients": "conditional_recipients",
4856
"filter": "filter",
4957
"name": "name",
5058
"recipients": "recipients",
@@ -53,25 +61,32 @@ def openapi_types(_):
5361
def __init__(
5462
self_,
5563
name: str,
56-
recipients: List[str],
64+
conditional_recipients: Union[MonitorNotificationRuleConditionalRecipients, UnsetType] = unset,
5765
filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset,
66+
recipients: Union[List[str], UnsetType] = unset,
5867
**kwargs,
5968
):
6069
"""
6170
Attributes of the monitor notification rule.
6271
72+
:param conditional_recipients: Use conditional recipients to define different recipients for different situations.
73+
:type conditional_recipients: MonitorNotificationRuleConditionalRecipients, optional
74+
6375
:param filter: Filter used to associate the notification rule with monitors.
6476
:type filter: MonitorNotificationRuleFilter, optional
6577
6678
:param name: The name of the monitor notification rule.
6779
:type name: str
6880
6981
:param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'.
70-
:type recipients: [str]
82+
:type recipients: [str], optional
7183
"""
84+
if conditional_recipients is not unset:
85+
kwargs["conditional_recipients"] = conditional_recipients
7286
if filter is not unset:
7387
kwargs["filter"] = filter
88+
if recipients is not unset:
89+
kwargs["recipients"] = recipients
7490
super().__init__(kwargs)
7591

7692
self_.name = name
77-
self_.recipients = recipients
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import List
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
class MonitorNotificationRuleCondition(ModelNormal):
15+
validations = {
16+
"recipients": {
17+
"max_items": 20,
18+
"min_items": 1,
19+
},
20+
"scope": {
21+
"max_length": 3000,
22+
"min_length": 1,
23+
},
24+
}
25+
26+
@cached_property
27+
def openapi_types(_):
28+
return {
29+
"recipients": ([str],),
30+
"scope": (str,),
31+
}
32+
33+
attribute_map = {
34+
"recipients": "recipients",
35+
"scope": "scope",
36+
}
37+
38+
def __init__(self_, recipients: List[str], scope: str, **kwargs):
39+
"""
40+
Conditions for ``conditional_recipients``.
41+
42+
:param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'.
43+
:type recipients: [str]
44+
45+
:param scope: The scope to which the monitor applied.
46+
:type scope: str
47+
"""
48+
super().__init__(kwargs)
49+
50+
self_.recipients = recipients
51+
self_.scope = scope
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import List, Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition
18+
19+
20+
class MonitorNotificationRuleConditionalRecipients(ModelNormal):
21+
validations = {
22+
"conditions": {
23+
"max_items": 10,
24+
"min_items": 1,
25+
},
26+
"fallback_recipients": {
27+
"max_items": 20,
28+
"min_items": 1,
29+
},
30+
}
31+
32+
@cached_property
33+
def openapi_types(_):
34+
from datadog_api_client.v2.model.monitor_notification_rule_condition import MonitorNotificationRuleCondition
35+
36+
return {
37+
"conditions": ([MonitorNotificationRuleCondition],),
38+
"fallback_recipients": ([str],),
39+
}
40+
41+
attribute_map = {
42+
"conditions": "conditions",
43+
"fallback_recipients": "fallback_recipients",
44+
}
45+
46+
def __init__(
47+
self_,
48+
conditions: List[MonitorNotificationRuleCondition],
49+
fallback_recipients: Union[List[str], UnsetType] = unset,
50+
**kwargs,
51+
):
52+
"""
53+
Use conditional recipients to define different recipients for different situations.
54+
55+
:param conditions: Conditions of the notification rule.
56+
:type conditions: [MonitorNotificationRuleCondition]
57+
58+
:param fallback_recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'.
59+
:type fallback_recipients: [str], optional
60+
"""
61+
if fallback_recipients is not unset:
62+
kwargs["fallback_recipients"] = fallback_recipients
63+
super().__init__(kwargs)
64+
65+
self_.conditions = conditions

0 commit comments

Comments
 (0)