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
32 changes: 32 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59535,6 +59535,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 @@ -59552,6 +59553,37 @@ components:
urgency:
$ref: "#/components/schemas/Urgency"
type: object
RoutingRuleEscalationPolicyAction:
description: "Routes the page to an escalation policy, optionally restricted to business hours."
properties:
ack_timeout_minutes:
description: "The number of minutes before an unacknowledged page is re-escalated."
example: 10
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/TimeRestrictions"
type:
$ref: "#/components/schemas/RoutingRuleEscalationPolicyActionType"
urgency:
$ref: "#/components/schemas/Urgency"
required:
- type
- policy_id
type: object
RoutingRuleEscalationPolicyActionType:
default: escalation_policy
description: "Indicates that the action routes to an escalation policy."
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
14 changes: 14 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26135,6 +26135,20 @@ 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\_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
33 changes: 31 additions & 2 deletions examples/v2/on-call/SetOnCallTeamRoutingRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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.routing_rule_escalation_policy_action import RoutingRuleEscalationPolicyAction
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_type import RoutingRuleEscalationPolicyActionType
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.team_routing_rules_request import TeamRoutingRulesRequest
Expand Down Expand Up @@ -55,9 +57,36 @@
),
),
TeamRoutingRulesRequestRule(
policy_id=ESCALATION_POLICY_DATA_ID,
actions=[
RoutingRuleEscalationPolicyAction(
ack_timeout_minutes=10,
policy_id=ESCALATION_POLICY_DATA_ID,
support_hours=TimeRestrictions(
time_zone="Europe/Paris",
restrictions=[
TimeRestriction(
end_day=Weekday.FRIDAY,
end_time="17:00:00",
start_day=Weekday.MONDAY,
start_time="09:00:00",
),
],
),
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
urgency=Urgency.LOW,
),
],
query="tags.service:test",
),
TeamRoutingRulesRequestRule(
actions=[
RoutingRuleEscalationPolicyAction(
policy_id=ESCALATION_POLICY_DATA_ID,
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
urgency=Urgency.LOW,
),
],
query="",
urgency=Urgency.LOW,
),
],
),
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 unacknowledged page is re-escalated.
: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: Holds time zone information and a list of time restrictions for a routing rule.
:type support_hours: TimeRestrictions, 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,
],
}
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 Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 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.time_restrictions import TimeRestrictions
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.time_restrictions import TimeRestrictions
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": (TimeRestrictions,),
"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[TimeRestrictions, UnsetType] = unset,
urgency: Union[Urgency, UnsetType] = unset,
**kwargs,
):
"""
Routes the page to an escalation policy, optionally restricted to business hours.

:param ack_timeout_minutes: The number of minutes before an unacknowledged page is re-escalated.
: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: Holds time zone information and a list of time restrictions for a routing rule.
:type support_hours: TimeRestrictions, optional

:param type: Indicates that the action routes to an escalation policy.
: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,35 @@
# 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 (
ModelSimple,
cached_property,
)

from typing import ClassVar


class RoutingRuleEscalationPolicyActionType(ModelSimple):
"""
Indicates that the action routes to an escalation policy.

:param value: If omitted defaults to "escalation_policy". Must be one of ["escalation_policy"].
:type value: str
"""

allowed_values = {
"escalation_policy",
}
ESCALATION_POLICY: ClassVar["RoutingRuleEscalationPolicyActionType"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY = RoutingRuleEscalationPolicyActionType("escalation_policy")
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 TeamRoutingRulesRequestRule(ModelNormal):
Expand Down Expand Up @@ -50,7 +51,11 @@ def __init__(
actions: Union[
List[
Union[
RoutingRuleAction, SendSlackMessageAction, SendTeamsMessageAction, TriggerWorkflowAutomationAction
RoutingRuleAction,
SendSlackMessageAction,
SendTeamsMessageAction,
TriggerWorkflowAutomationAction,
RoutingRuleEscalationPolicyAction,
]
],
UnsetType,
Expand Down
4 changes: 4 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5353,6 +5353,8 @@
from datadog_api_client.v2.model.routing_rule import RoutingRule
from datadog_api_client.v2.model.routing_rule_action import RoutingRuleAction
from datadog_api_client.v2.model.routing_rule_attributes import RoutingRuleAttributes
from datadog_api_client.v2.model.routing_rule_escalation_policy_action import RoutingRuleEscalationPolicyAction
from datadog_api_client.v2.model.routing_rule_escalation_policy_action_type import RoutingRuleEscalationPolicyActionType
from datadog_api_client.v2.model.routing_rule_relationships import RoutingRuleRelationships
from datadog_api_client.v2.model.routing_rule_relationships_policy import RoutingRuleRelationshipsPolicy
from datadog_api_client.v2.model.routing_rule_relationships_policy_data import RoutingRuleRelationshipsPolicyData
Expand Down Expand Up @@ -11308,6 +11310,8 @@
"RoutingRule",
"RoutingRuleAction",
"RoutingRuleAttributes",
"RoutingRuleEscalationPolicyAction",
"RoutingRuleEscalationPolicyActionType",
"RoutingRuleRelationships",
"RoutingRuleRelationshipsPolicy",
"RoutingRuleRelationshipsPolicyData",
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/features/on-call.feature
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Feature: On-Call
And there is a valid "schedule" in the system
And there is a valid "escalation_policy" in the system
And request contains "team_id" parameter from "dd_team.data.id"
And body with value {"data": {"attributes": {"rules": [{"actions": [{"channel": "channel", "type": "send_slack_message", "workspace": "workspace"}], "query": "tags.service:test", "time_restriction": {"time_zone": "Europe/Paris", "restrictions": [{"end_day": "monday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}, {"end_day": "tuesday", "end_time": "17:00:00", "start_day": "tuesday", "start_time": "09:00:00"}]}}, {"policy_id": "{{ escalation_policy.data.id }}", "query": "", "urgency": "low"}]}, "id": "{{ dd_team.data.id }}", "type": "team_routing_rules"}}
And body with value {"data": {"attributes": {"rules": [{"actions": [{"channel": "channel", "type": "send_slack_message", "workspace": "workspace"}], "query": "tags.service:test", "time_restriction": {"time_zone": "Europe/Paris", "restrictions": [{"end_day": "monday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}, {"end_day": "tuesday", "end_time": "17:00:00", "start_day": "tuesday", "start_time": "09:00:00"}]}}, {"actions": [{"ack_timeout_minutes": 10, "policy_id": "{{ escalation_policy.data.id }}", "support_hours": {"time_zone": "Europe/Paris", "restrictions": [{"end_day": "friday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}]}, "type": "escalation_policy", "urgency": "low"}], "query": "tags.service:test"}, {"actions": [{"policy_id": "{{ escalation_policy.data.id }}", "type": "escalation_policy", "urgency": "low"}], "query": ""}]}, "id": "{{ dd_team.data.id }}", "type": "team_routing_rules"}}
And request contains "include" parameter with value "rules"
When the request is sent
Then the response status is 200 OK
Expand Down
Loading