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
49 changes: 48 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65461,6 +65461,7 @@ components:
- $ref: "#/components/schemas/SendSlackMessageAction"
- $ref: "#/components/schemas/SendTeamsMessageAction"
- $ref: "#/components/schemas/TriggerWorkflowAutomationAction"
- $ref: "#/components/schemas/RoutingRuleEscalationPolicyAction"
RoutingRuleAttributes:
description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
properties:
Expand All @@ -65478,6 +65479,52 @@ components:
urgency:
$ref: "#/components/schemas/Urgency"
type: object
RoutingRuleEscalationPolicyAction:
description: "Triggers an escalation policy."
properties:
ack_timeout_minutes:
description: "The number of minutes before an acknowledged page is re-triggered."
example: 30
format: int64
type: integer
policy_id:
description: "The ID of the escalation policy to route to."
example: "00000000-0000-0000-0000-000000000000"
type: string
support_hours:
$ref: "#/components/schemas/RoutingRuleEscalationPolicyActionSupportHours"
type:
$ref: "#/components/schemas/RoutingRuleEscalationPolicyActionType"
urgency:
$ref: "#/components/schemas/Urgency"
required:
- type
- policy_id
type: object
RoutingRuleEscalationPolicyActionSupportHours:
description: "Support hours during which the escalation policy will be executed. Outside of these hours, the escalation policy will be on hold and triggered once the next support hours window starts. This is mutually exclusive with the top-level `time_restriction` field on the routing rule."
properties:
restrictions:
description: "The list of support hours time windows."
items:
$ref: "#/components/schemas/TimeRestriction"
type: array
time_zone:
description: "The time zone in which the support hours are expressed."
example: ""
type: string
required:
- time_zone
type: object
RoutingRuleEscalationPolicyActionType:
default: escalation_policy
description: "Indicates that the action pages an escalation policy. This action can be set once per routing rule item, and is mutually exclusive with the top-level `policy_id` field on the routing rule."
enum:
- escalation_policy
example: escalation_policy
type: string
x-enum-varnames:
- ESCALATION_POLICY
RoutingRuleRelationships:
description: Specifies relationships for a routing rule, linking to associated policy resources.
properties:
Expand Down Expand Up @@ -85180,7 +85227,7 @@ components:
type: string
type: object
TimeRestrictions:
description: Holds time zone information and a list of time restrictions for a routing rule.
description: Time restrictions during which the routing rule is active. Outside of these hours, the rule does not match and routing continues to subsequent rules. This is mutually exclusive with the action-level `support_hours` field.
properties:
restrictions:
description: Defines the list of time-based restrictions.
Expand Down
21 changes: 21 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28452,6 +28452,27 @@ datadog\_api\_client.v2.model.routing\_rule\_attributes module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.routing\_rule\_escalation\_policy\_action module
------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.routing_rule_escalation_policy_action
:members:
:show-inheritance:

datadog\_api\_client.v2.model.routing\_rule\_escalation\_policy\_action\_support\_hours module
----------------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.routing_rule_escalation_policy_action_support_hours
:members:
:show-inheritance:

datadog\_api\_client.v2.model.routing\_rule\_escalation\_policy\_action\_type module
------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.routing_rule_escalation_policy_action_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.routing\_rule\_relationships module
-----------------------------------------------------------------

Expand Down
57 changes: 49 additions & 8 deletions examples/v2/on-call/SetOnCallTeamRoutingRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.on_call_api import OnCallApi
from datadog_api_client.v2.model.send_slack_message_action import SendSlackMessageAction
from datadog_api_client.v2.model.send_slack_message_action_type import SendSlackMessageActionType
from datadog_api_client.v2.model.routing_rule_escalation_policy_action import RoutingRuleEscalationPolicyAction
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_support_hours import (
RoutingRuleEscalationPolicyActionSupportHours,
)
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_type import RoutingRuleEscalationPolicyActionType
from datadog_api_client.v2.model.team_routing_rules_request import TeamRoutingRulesRequest
from datadog_api_client.v2.model.team_routing_rules_request_data import TeamRoutingRulesRequestData
from datadog_api_client.v2.model.team_routing_rules_request_data_attributes import TeamRoutingRulesRequestDataAttributes
Expand All @@ -29,13 +32,13 @@
rules=[
TeamRoutingRulesRequestRule(
actions=[
SendSlackMessageAction(
channel="channel",
type=SendSlackMessageActionType.SEND_SLACK_MESSAGE,
workspace="workspace",
RoutingRuleEscalationPolicyAction(
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
policy_id=ESCALATION_POLICY_DATA_ID,
urgency=Urgency.LOW,
),
],
query="tags.service:test",
query="tags.service:time_restrictions",
time_restriction=TimeRestrictions(
time_zone="Europe/Paris",
restrictions=[
Expand All @@ -54,11 +57,49 @@
],
),
),
TeamRoutingRulesRequestRule(
actions=[
RoutingRuleEscalationPolicyAction(
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
policy_id=ESCALATION_POLICY_DATA_ID,
urgency=Urgency.LOW,
ack_timeout_minutes=30,
support_hours=RoutingRuleEscalationPolicyActionSupportHours(
time_zone="Europe/Paris",
restrictions=[
TimeRestriction(
end_day=Weekday.WEDNESDAY,
end_time="17:00:00",
start_day=Weekday.WEDNESDAY,
start_time="09:00:00",
),
TimeRestriction(
end_day=Weekday.THURSDAY,
end_time="17:00:00",
start_day=Weekday.THURSDAY,
start_time="09:00:00",
),
],
),
),
],
query="tags.service:support_hours_and_acknowledgment_timeout",
),
TeamRoutingRulesRequestRule(
policy_id=ESCALATION_POLICY_DATA_ID,
query="",
query="tags.service:legacy_policy_definition",
urgency=Urgency.LOW,
),
TeamRoutingRulesRequestRule(
actions=[
RoutingRuleEscalationPolicyAction(
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
policy_id=ESCALATION_POLICY_DATA_ID,
urgency=Urgency.LOW,
),
],
query="",
),
],
),
id=DD_TEAM_DATA_ID,
Expand Down
14 changes: 14 additions & 0 deletions src/datadog_api_client/v2/model/routing_rule_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ def __init__(self, **kwargs):

:param handle: The handle of the Workflow Automation to trigger.
:type handle: str

:param ack_timeout_minutes: The number of minutes before an acknowledged page is re-triggered.
:type ack_timeout_minutes: int, optional

:param policy_id: The ID of the escalation policy to route to.
:type policy_id: str

:param support_hours: Support hours during which the escalation policy will be executed. Outside of these hours, the escalation policy will be on hold and triggered once the next support hours window starts. This is mutually exclusive with the top-level `time_restriction` field on the routing rule.
:type support_hours: RoutingRuleEscalationPolicyActionSupportHours, optional

:param urgency: Specifies the level of urgency for a routing rule (low, high, or dynamic).
:type urgency: Urgency, optional
"""
super().__init__(kwargs)

Expand All @@ -47,11 +59,13 @@ def _composed_schemas(_):
from datadog_api_client.v2.model.send_slack_message_action import SendSlackMessageAction
from datadog_api_client.v2.model.send_teams_message_action import SendTeamsMessageAction
from datadog_api_client.v2.model.trigger_workflow_automation_action import TriggerWorkflowAutomationAction
from datadog_api_client.v2.model.routing_rule_escalation_policy_action import RoutingRuleEscalationPolicyAction

return {
"oneOf": [
SendSlackMessageAction,
SendTeamsMessageAction,
TriggerWorkflowAutomationAction,
RoutingRuleEscalationPolicyAction,
],
}
9 changes: 7 additions & 2 deletions src/datadog_api_client/v2/model/routing_rule_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from datadog_api_client.v2.model.send_slack_message_action import SendSlackMessageAction
from datadog_api_client.v2.model.send_teams_message_action import SendTeamsMessageAction
from datadog_api_client.v2.model.trigger_workflow_automation_action import TriggerWorkflowAutomationAction
from datadog_api_client.v2.model.routing_rule_escalation_policy_action import RoutingRuleEscalationPolicyAction


class RoutingRuleAttributes(ModelNormal):
Expand Down Expand Up @@ -48,7 +49,11 @@ def __init__(
actions: Union[
List[
Union[
RoutingRuleAction, SendSlackMessageAction, SendTeamsMessageAction, TriggerWorkflowAutomationAction
RoutingRuleAction,
SendSlackMessageAction,
SendTeamsMessageAction,
TriggerWorkflowAutomationAction,
RoutingRuleEscalationPolicyAction,
]
],
UnsetType,
Expand All @@ -67,7 +72,7 @@ def __init__(
:param query: Defines the query or condition that triggers this routing rule.
:type query: str, optional

:param time_restriction: Holds time zone information and a list of time restrictions for a routing rule.
:param time_restriction: Time restrictions during which the routing rule is active. Outside of these hours, the rule does not match and routing continues to subsequent rules. This is mutually exclusive with the action-level ``support_hours`` field.
:type time_restriction: TimeRestrictions, optional

:param urgency: Specifies the level of urgency for a routing rule (low, high, or dynamic).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 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 typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_support_hours import (
RoutingRuleEscalationPolicyActionSupportHours,
)
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_type import (
RoutingRuleEscalationPolicyActionType,
)
from datadog_api_client.v2.model.urgency import Urgency


class RoutingRuleEscalationPolicyAction(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_support_hours import (
RoutingRuleEscalationPolicyActionSupportHours,
)
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_type import (
RoutingRuleEscalationPolicyActionType,
)
from datadog_api_client.v2.model.urgency import Urgency

return {
"ack_timeout_minutes": (int,),
"policy_id": (str,),
"support_hours": (RoutingRuleEscalationPolicyActionSupportHours,),
"type": (RoutingRuleEscalationPolicyActionType,),
"urgency": (Urgency,),
}

attribute_map = {
"ack_timeout_minutes": "ack_timeout_minutes",
"policy_id": "policy_id",
"support_hours": "support_hours",
"type": "type",
"urgency": "urgency",
}

def __init__(
self_,
policy_id: str,
type: RoutingRuleEscalationPolicyActionType,
ack_timeout_minutes: Union[int, UnsetType] = unset,
support_hours: Union[RoutingRuleEscalationPolicyActionSupportHours, UnsetType] = unset,
urgency: Union[Urgency, UnsetType] = unset,
**kwargs,
):
"""
Triggers an escalation policy.

:param ack_timeout_minutes: The number of minutes before an acknowledged page is re-triggered.
:type ack_timeout_minutes: int, optional

:param policy_id: The ID of the escalation policy to route to.
:type policy_id: str

:param support_hours: Support hours during which the escalation policy will be executed. Outside of these hours, the escalation policy will be on hold and triggered once the next support hours window starts. This is mutually exclusive with the top-level ``time_restriction`` field on the routing rule.
:type support_hours: RoutingRuleEscalationPolicyActionSupportHours, optional

:param type: Indicates that the action pages an escalation policy. This action can be set once per routing rule item, and is mutually exclusive with the top-level ``policy_id`` field on the routing rule.
:type type: RoutingRuleEscalationPolicyActionType

:param urgency: Specifies the level of urgency for a routing rule (low, high, or dynamic).
:type urgency: Urgency, optional
"""
if ack_timeout_minutes is not unset:
kwargs["ack_timeout_minutes"] = ack_timeout_minutes
if support_hours is not unset:
kwargs["support_hours"] = support_hours
if urgency is not unset:
kwargs["urgency"] = urgency
super().__init__(kwargs)

self_.policy_id = policy_id
self_.type = type
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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 typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.time_restriction import TimeRestriction


class RoutingRuleEscalationPolicyActionSupportHours(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.time_restriction import TimeRestriction

return {
"restrictions": ([TimeRestriction],),
"time_zone": (str,),
}

attribute_map = {
"restrictions": "restrictions",
"time_zone": "time_zone",
}

def __init__(self_, time_zone: str, restrictions: Union[List[TimeRestriction], UnsetType] = unset, **kwargs):
"""
Support hours during which the escalation policy will be executed. Outside of these hours, the escalation policy will be on hold and triggered once the next support hours window starts. This is mutually exclusive with the top-level ``time_restriction`` field on the routing rule.

:param restrictions: The list of support hours time windows.
:type restrictions: [TimeRestriction], optional

:param time_zone: The time zone in which the support hours are expressed.
:type time_zone: str
"""
if restrictions is not unset:
kwargs["restrictions"] = restrictions
super().__init__(kwargs)

self_.time_zone = time_zone
Loading
Loading