Skip to content
Closed
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
71 changes: 64 additions & 7 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61454,8 +61454,14 @@ components:
description: "Trigger a workflow when an incident is declared."
properties:
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
tagCondition:
$ref: "#/components/schemas/IncidentCondition"
type: object
Expand Down Expand Up @@ -62154,8 +62160,14 @@ components:
executionLimit:
$ref: "#/components/schemas/ExecutionLimit"
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
tagCondition:
$ref: "#/components/schemas/IncidentCondition"
type: object
Expand Down Expand Up @@ -62473,8 +62485,14 @@ components:
executionLimit:
$ref: "#/components/schemas/ExecutionLimit"
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
tagCondition:
$ref: "#/components/schemas/IncidentCondition"
type: object
Expand Down Expand Up @@ -63715,8 +63733,14 @@ components:
executionLimit:
$ref: "#/components/schemas/ExecutionLimit"
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
tagCondition:
$ref: "#/components/schemas/IncidentCondition"
type: object
Expand Down Expand Up @@ -63766,8 +63790,14 @@ components:
executionLimit:
$ref: "#/components/schemas/ExecutionLimit"
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
tagCondition:
$ref: "#/components/schemas/IncidentCondition"
type: object
Expand Down Expand Up @@ -64751,8 +64781,14 @@ components:
executionLimit:
$ref: "#/components/schemas/ExecutionLimit"
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
serialExecution:
$ref: "#/components/schemas/SerialExecution"
tagCondition:
Expand All @@ -64772,8 +64808,14 @@ components:
description: "Trigger a workflow on a schedule for an incident."
properties:
incidentType:
description: "The type of incident that triggers the workflow."
deprecated: true
description: "The type of incident that triggers the workflow. Deprecated. Use `incidentTypes` instead."
type: string
incidentTypes:
description: "The types of incidents that trigger the workflow."
items:
type: string
type: array
rrule:
description: "The recurrence rule for the schedule, expressed as an iCalendar `RRULE` string."
example: "DTSTART:20241220T151700Z\nRRULE:FREQ=MONTHLY"
Expand Down Expand Up @@ -83346,6 +83388,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 @@ -83486,6 +83530,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 @@ -83563,6 +83618,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)
12 changes: 10 additions & 2 deletions src/datadog_api_client/v2/model/incident_created_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
Expand All @@ -24,31 +24,39 @@ def openapi_types(_):

return {
"incident_type": (str,),
"incident_types": ([str],),
"tag_condition": (IncidentCondition,),
}

attribute_map = {
"incident_type": "incidentType",
"incident_types": "incidentTypes",
"tag_condition": "tagCondition",
}

def __init__(
self_,
incident_type: Union[str, UnsetType] = unset,
incident_types: Union[List[str], UnsetType] = unset,
tag_condition: Union[IncidentCondition, UnsetType] = unset,
**kwargs,
):
"""
Trigger a workflow when an incident is declared.

:param incident_type: The type of incident that triggers the workflow.
:param incident_type: The type of incident that triggers the workflow. Deprecated. Use ``incidentTypes`` instead. **Deprecated**.
:type incident_type: str, optional

:param incident_types: The types of incidents that trigger the workflow.
:type incident_types: [str], optional

:param tag_condition: Conditions that determine which incidents trigger the workflow.
:type tag_condition: IncidentCondition, optional
"""
if incident_type is not unset:
kwargs["incident_type"] = incident_type
if incident_types is not unset:
kwargs["incident_types"] = incident_types
if tag_condition is not unset:
kwargs["tag_condition"] = tag_condition
super().__init__(kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
Expand All @@ -27,19 +27,22 @@ def openapi_types(_):
return {
"execution_limit": (ExecutionLimit,),
"incident_type": (str,),
"incident_types": ([str],),
"tag_condition": (IncidentCondition,),
}

attribute_map = {
"execution_limit": "executionLimit",
"incident_type": "incidentType",
"incident_types": "incidentTypes",
"tag_condition": "tagCondition",
}

def __init__(
self_,
execution_limit: Union[ExecutionLimit, UnsetType] = unset,
incident_type: Union[str, UnsetType] = unset,
incident_types: Union[List[str], UnsetType] = unset,
tag_condition: Union[IncidentCondition, UnsetType] = unset,
**kwargs,
):
Expand All @@ -49,16 +52,21 @@ def __init__(
:param execution_limit: The maximum number of times to execute a workflow for an incident.
:type execution_limit: ExecutionLimit, optional

:param incident_type: The type of incident that triggers the workflow.
:param incident_type: The type of incident that triggers the workflow. Deprecated. Use ``incidentTypes`` instead. **Deprecated**.
:type incident_type: str, optional

:param incident_types: The types of incidents that trigger the workflow.
:type incident_types: [str], optional

:param tag_condition: Conditions that determine which incidents trigger the workflow.
:type tag_condition: IncidentCondition, optional
"""
if execution_limit is not unset:
kwargs["execution_limit"] = execution_limit
if incident_type is not unset:
kwargs["incident_type"] = incident_type
if incident_types is not unset:
kwargs["incident_types"] = incident_types
if tag_condition is not unset:
kwargs["tag_condition"] = tag_condition
super().__init__(kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
Expand All @@ -27,19 +27,22 @@ def openapi_types(_):
return {
"execution_limit": (ExecutionLimit,),
"incident_type": (str,),
"incident_types": ([str],),
"tag_condition": (IncidentCondition,),
}

attribute_map = {
"execution_limit": "executionLimit",
"incident_type": "incidentType",
"incident_types": "incidentTypes",
"tag_condition": "tagCondition",
}

def __init__(
self_,
execution_limit: Union[ExecutionLimit, UnsetType] = unset,
incident_type: Union[str, UnsetType] = unset,
incident_types: Union[List[str], UnsetType] = unset,
tag_condition: Union[IncidentCondition, UnsetType] = unset,
**kwargs,
):
Expand All @@ -49,16 +52,21 @@ def __init__(
:param execution_limit: The maximum number of times to execute a workflow for an incident.
:type execution_limit: ExecutionLimit, optional

:param incident_type: The type of incident that triggers the workflow.
:param incident_type: The type of incident that triggers the workflow. Deprecated. Use ``incidentTypes`` instead. **Deprecated**.
:type incident_type: str, optional

:param incident_types: The types of incidents that trigger the workflow.
:type incident_types: [str], optional

:param tag_condition: Conditions that determine which incidents trigger the workflow.
:type tag_condition: IncidentCondition, optional
"""
if execution_limit is not unset:
kwargs["execution_limit"] = execution_limit
if incident_type is not unset:
kwargs["incident_type"] = incident_type
if incident_types is not unset:
kwargs["incident_types"] = incident_types
if tag_condition is not unset:
kwargs["tag_condition"] = tag_condition
super().__init__(kwargs)
Loading
Loading