On-call 팀 라우팅 규칙 설정
https://api.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.us3.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.us5.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.datadoghq.eu/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.ap1.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.ap2.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.uk1.datadoghq.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.ddog-gov.com/api/v2/on-call/teams/{team_id}/routing-ruleshttps://api.us2.ddog-gov.com/api/v2/on-call/teams/{team_id}/routing-rules개요
팀의 On-Call 라우팅 규칙을 설정합니다.
인수
경로 파라미터
team_id [required]The team ID
쿼리 문자열
includeComma-separated list of included relationships to be returned. Allowed values: rules, rules.policy.
요청
Body Data (required)
data데이터 페이로드를 포함하여 팀 라우팅 규칙을 생성하거나 업데이트하라는 요청을 나타냅니다.
attributesRepresents the attributes of a request to update or create team routing rules.
rulesA list of routing rule items that define how incoming pages should be handled.
actionsSpecifies the list of actions to perform when the routing rule is matched.
<type=send_slack_message>Sends a message to a Slack channel.
channel [required]The channel ID.
type [required]Indicates that the action is a send Slack message action.
send_slack_messagesend_slack_messageworkspace [required]The workspace ID.
<type=send_teams_message>Sends a message to a Microsoft Teams channel.
channel [required]The channel ID.
team [required]The team ID.
tenant [required]The tenant ID.
type [required]Indicates that the action is a send Microsoft Teams message action.
send_teams_messagesend_teams_message<type=workflow>Triggers a Workflow Automation.
handle [required]The handle of the Workflow Automation to trigger.
type [required]Indicates that the action triggers a Workflow Automation.
workflowworkflow<type=escalation_policy>Triggers an escalation policy.
ack_timeout_minutesThe number of minutes before an acknowledged page is re-triggered.
policy_id [required]The ID of the escalation policy to route to.
support_hoursSupport 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.
restrictionsThe list of support hours time windows.
end_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundayend_timeSpecifies the ending time for this restriction.
start_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundaystart_timeSpecifies the starting time for this restriction.
time_zone [required]The time zone in which the support hours are expressed.
type [required]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.
escalation_policyescalation_policyurgencySpecifies the level of urgency for a routing rule (low, high, or dynamic).
low, high, dynamic<type=reroute_to_team>Reroutes the page to another team, which then evaluates it against its own routing rules. Each routing rule can include this action only once. It can be combined only with send_slack_message and send_teams_message actions. It can't be used with escalation_policy or workflow actions, or when the routing rule sets policy_id.
destination_team_id [required]The ID of the team to reroute the page to.
type [required]Indicates that the action reroutes the page to another team's routing rules.
reroute_to_teamreroute_to_teamidSpecifies the unique identifier of an existing routing rule to update. If omitted, a new routing rule is created.
policy_idIdentifies the policy to be applied when this routing rule matches.
queryDefines the query or condition that triggers this routing rule.
time_restrictionTime 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.
restrictions [required]Defines the list of time-based restrictions.
end_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundayend_timeSpecifies the ending time for this restriction.
start_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundaystart_timeSpecifies the starting time for this restriction.
time_zone [required]Specifies the time zone applicable to the restrictions.
urgencySpecifies the level of urgency for a routing rule (low, high, or dynamic).
low, high, dynamicidSpecifies the unique identifier for this set of team routing rules.
type [required]Team routing rules resource type.
team_routing_rulesteam_routing_rules{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}응답
OK
Represents a complete set of team routing rules, including data and optionally included related resources.
dataRepresents the top-level data object for team routing rules, containing the ID, relationships, and resource type.
idSpecifies the unique identifier of this team routing rules record.
relationshipsSpecifies relationships for team routing rules, including rule references.
rulesHolds references to a set of routing rules in a relationship.
dataAn array of references to the routing rules associated with this team.
id [required]Specifies the unique identifier for the related routing rule.
type [required]Indicates that the resource is of type 'team_routing_rules'.
team_routing_rulesteam_routing_rulestype [required]Team routing rules resource type.
team_routing_rulesteam_routing_rulesincludedProvides related routing rules or other included resources.
<type=team_routing_rules>Represents a routing rule, including its attributes, relationships, and unique identifier.
attributesDefines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
actionsSpecifies the list of actions to perform when the routing rule matches.
<type=send_slack_message>Sends a message to a Slack channel.
channel [required]The channel ID.
type [required]Indicates that the action is a send Slack message action.
send_slack_messagesend_slack_messageworkspace [required]The workspace ID.
<type=send_teams_message>Sends a message to a Microsoft Teams channel.
channel [required]The channel ID.
team [required]The team ID.
tenant [required]The tenant ID.
type [required]Indicates that the action is a send Microsoft Teams message action.
send_teams_messagesend_teams_message<type=workflow>Triggers a Workflow Automation.
handle [required]The handle of the Workflow Automation to trigger.
type [required]Indicates that the action triggers a Workflow Automation.
workflowworkflow<type=escalation_policy>Triggers an escalation policy.
ack_timeout_minutesThe number of minutes before an acknowledged page is re-triggered.
policy_id [required]The ID of the escalation policy to route to.
support_hoursSupport 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.
restrictionsThe list of support hours time windows.
end_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundayend_timeSpecifies the ending time for this restriction.
start_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundaystart_timeSpecifies the starting time for this restriction.
time_zone [required]The time zone in which the support hours are expressed.
type [required]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.
escalation_policyescalation_policyurgencySpecifies the level of urgency for a routing rule (low, high, or dynamic).
low, high, dynamic<type=reroute_to_team>Reroutes the page to another team, which then evaluates it against its own routing rules. Each routing rule can include this action only once. It can be combined only with send_slack_message and send_teams_message actions. It can't be used with escalation_policy or workflow actions, or when the routing rule sets policy_id.
destination_team_id [required]The ID of the team to reroute the page to.
type [required]Indicates that the action reroutes the page to another team's routing rules.
reroute_to_teamreroute_to_teamqueryDefines the query or condition that triggers this routing rule.
time_restrictionTime 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.
restrictions [required]Defines the list of time-based restrictions.
end_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundayend_timeSpecifies the ending time for this restriction.
start_dayA day of the week.
monday, tuesday, wednesday, thursday, friday, saturday, sundaystart_timeSpecifies the starting time for this restriction.
time_zone [required]Specifies the time zone applicable to the restrictions.
urgencySpecifies the level of urgency for a routing rule (low, high, or dynamic).
low, high, dynamicidSpecifies the unique identifier of this routing rule.
relationshipsSpecifies relationships for a routing rule, linking to associated policy resources.
policyDefines the relationship that links a routing rule to a policy.
dataRepresents the policy data reference, containing the policy's ID and resource type.
id [required]Specifies the unique identifier of the policy.
type [required]Indicates that the resource is of type 'policies'.
policiespoliciestype [required]Team routing rules resource type.
team_routing_rulesteam_routing_rules{
"data": {
"id": "27590dae-47be-4a7d-9abf-8f4e45124020",
"relationships": {
"rules": {
"data": [
{
"id": "03aff2d6-6cbf-496c-997f-a857bbe9a94a",
"type": "team_routing_rules"
},
{
"id": "03aff2d6-6cbf-496c-997f-a857bbe9a94a",
"type": "team_routing_rules"
}
]
}
},
"type": "team_routing_rules"
},
"included": [
{
"attributes": {
"actions": null,
"query": "tags.service:test",
"time_restriction": {
"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"
}
],
"time_zone": ""
},
"urgency": "high"
},
"id": "03aff2d6-6cbf-496c-997f-a857bbe9a94a",
"relationships": {
"policy": {
"data": null
}
},
"type": "team_routing_rules"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}코드 예시
# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF# Path parameters
export team_id="27590dae-47be-4a7d-9abf-8f4e45124020"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v2/on-call/teams/${team_id}/routing-rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"rules": [
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": "tags.service:time_restrictions",
"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": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low",
"ack_timeout_minutes": 30,
"support_hours": {
"time_zone": "Europe/Paris",
"restrictions": [
{
"end_day": "wednesday",
"end_time": "17:00:00",
"start_day": "wednesday",
"start_time": "09:00:00"
},
{
"end_day": "thursday",
"end_time": "17:00:00",
"start_day": "thursday",
"start_time": "09:00:00"
}
]
}
}
],
"query": "tags.service:support_hours_and_acknowledgment_timeout"
},
{
"policy_id": "ab000000-0000-0000-0000-000000000000",
"query": "tags.service:legacy_policy_definition",
"urgency": "low"
},
{
"actions": [
{
"type": "escalation_policy",
"policy_id": "ab000000-0000-0000-0000-000000000000",
"urgency": "low"
}
],
"query": ""
}
]
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "team_routing_rules"
}
}
EOF// Set On-Call team routing rules returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
// there is a valid "dd_team" in the system
DdTeamDataID := os.Getenv("DD_TEAM_DATA_ID")
// there is a valid "escalation_policy" in the system
EscalationPolicyDataID := os.Getenv("ESCALATION_POLICY_DATA_ID")
body := datadogV2.TeamRoutingRulesRequest{
Data: &datadogV2.TeamRoutingRulesRequestData{
Attributes: &datadogV2.TeamRoutingRulesRequestDataAttributes{
Rules: []datadogV2.TeamRoutingRulesRequestRule{
{
Actions: []datadogV2.RoutingRuleAction{
datadogV2.RoutingRuleAction{
RoutingRuleEscalationPolicyAction: &datadogV2.RoutingRuleEscalationPolicyAction{
Type: datadogV2.ROUTINGRULEESCALATIONPOLICYACTIONTYPE_ESCALATION_POLICY,
PolicyId: EscalationPolicyDataID,
Urgency: datadogV2.URGENCY_LOW.Ptr(),
}},
},
Query: datadog.PtrString("tags.service:time_restrictions"),
TimeRestriction: &datadogV2.TimeRestrictions{
TimeZone: "Europe/Paris",
Restrictions: []datadogV2.TimeRestriction{
{
EndDay: datadogV2.WEEKDAY_MONDAY.Ptr(),
EndTime: datadog.PtrString("17:00:00"),
StartDay: datadogV2.WEEKDAY_MONDAY.Ptr(),
StartTime: datadog.PtrString("09:00:00"),
},
{
EndDay: datadogV2.WEEKDAY_TUESDAY.Ptr(),
EndTime: datadog.PtrString("17:00:00"),
StartDay: datadogV2.WEEKDAY_TUESDAY.Ptr(),
StartTime: datadog.PtrString("09:00:00"),
},
},
},
},
{
Actions: []datadogV2.RoutingRuleAction{
datadogV2.RoutingRuleAction{
RoutingRuleEscalationPolicyAction: &datadogV2.RoutingRuleEscalationPolicyAction{
Type: datadogV2.ROUTINGRULEESCALATIONPOLICYACTIONTYPE_ESCALATION_POLICY,
PolicyId: EscalationPolicyDataID,
Urgency: datadogV2.URGENCY_LOW.Ptr(),
AckTimeoutMinutes: datadog.PtrInt64(30),
SupportHours: &datadogV2.RoutingRuleEscalationPolicyActionSupportHours{
TimeZone: "Europe/Paris",
Restrictions: []datadogV2.TimeRestriction{
{
EndDay: datadogV2.WEEKDAY_WEDNESDAY.Ptr(),
EndTime: datadog.PtrString("17:00:00"),
StartDay: datadogV2.WEEKDAY_WEDNESDAY.Ptr(),
StartTime: datadog.PtrString("09:00:00"),
},
{
EndDay: datadogV2.WEEKDAY_THURSDAY.Ptr(),
EndTime: datadog.PtrString("17:00:00"),
StartDay: datadogV2.WEEKDAY_THURSDAY.Ptr(),
StartTime: datadog.PtrString("09:00:00"),
},
},
},
}},
},
Query: datadog.PtrString("tags.service:support_hours_and_acknowledgment_timeout"),
},
{
PolicyId: datadog.PtrString(EscalationPolicyDataID),
Query: datadog.PtrString("tags.service:legacy_policy_definition"),
Urgency: datadogV2.URGENCY_LOW.Ptr(),
},
{
Actions: []datadogV2.RoutingRuleAction{
datadogV2.RoutingRuleAction{
RoutingRuleEscalationPolicyAction: &datadogV2.RoutingRuleEscalationPolicyAction{
Type: datadogV2.ROUTINGRULEESCALATIONPOLICYACTIONTYPE_ESCALATION_POLICY,
PolicyId: EscalationPolicyDataID,
Urgency: datadogV2.URGENCY_LOW.Ptr(),
}},
},
Query: datadog.PtrString(""),
},
},
},
Id: datadog.PtrString(DdTeamDataID),
Type: datadogV2.TEAMROUTINGRULESREQUESTDATATYPE_TEAM_ROUTING_RULES,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewOnCallApi(apiClient)
resp, r, err := api.SetOnCallTeamRoutingRules(ctx, DdTeamDataID, body, *datadogV2.NewSetOnCallTeamRoutingRulesOptionalParameters().WithInclude("rules"))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OnCallApi.SetOnCallTeamRoutingRules`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `OnCallApi.SetOnCallTeamRoutingRules`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Set On-Call team routing rules returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.OnCallApi;
import com.datadog.api.client.v2.api.OnCallApi.SetOnCallTeamRoutingRulesOptionalParameters;
import com.datadog.api.client.v2.model.RoutingRuleAction;
import com.datadog.api.client.v2.model.RoutingRuleEscalationPolicyAction;
import com.datadog.api.client.v2.model.RoutingRuleEscalationPolicyActionSupportHours;
import com.datadog.api.client.v2.model.RoutingRuleEscalationPolicyActionType;
import com.datadog.api.client.v2.model.TeamRoutingRules;
import com.datadog.api.client.v2.model.TeamRoutingRulesRequest;
import com.datadog.api.client.v2.model.TeamRoutingRulesRequestData;
import com.datadog.api.client.v2.model.TeamRoutingRulesRequestDataAttributes;
import com.datadog.api.client.v2.model.TeamRoutingRulesRequestDataType;
import com.datadog.api.client.v2.model.TeamRoutingRulesRequestRule;
import com.datadog.api.client.v2.model.TimeRestriction;
import com.datadog.api.client.v2.model.TimeRestrictions;
import com.datadog.api.client.v2.model.Urgency;
import com.datadog.api.client.v2.model.Weekday;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
OnCallApi apiInstance = new OnCallApi(defaultClient);
// there is a valid "dd_team" in the system
String DD_TEAM_DATA_ID = System.getenv("DD_TEAM_DATA_ID");
// there is a valid "escalation_policy" in the system
String ESCALATION_POLICY_DATA_ID = System.getenv("ESCALATION_POLICY_DATA_ID");
TeamRoutingRulesRequest body =
new TeamRoutingRulesRequest()
.data(
new TeamRoutingRulesRequestData()
.attributes(
new TeamRoutingRulesRequestDataAttributes()
.rules(
Arrays.asList(
new TeamRoutingRulesRequestRule()
.actions(
Collections.singletonList(
new RoutingRuleAction(
new RoutingRuleEscalationPolicyAction()
.type(
RoutingRuleEscalationPolicyActionType
.ESCALATION_POLICY)
.policyId(ESCALATION_POLICY_DATA_ID)
.urgency(Urgency.LOW))))
.query("tags.service:time_restrictions")
.timeRestriction(
new TimeRestrictions()
.timeZone("Europe/Paris")
.restrictions(
Arrays.asList(
new TimeRestriction()
.endDay(Weekday.MONDAY)
.endTime("17:00:00")
.startDay(Weekday.MONDAY)
.startTime("09:00:00"),
new TimeRestriction()
.endDay(Weekday.TUESDAY)
.endTime("17:00:00")
.startDay(Weekday.TUESDAY)
.startTime("09:00:00")))),
new TeamRoutingRulesRequestRule()
.actions(
Collections.singletonList(
new RoutingRuleAction(
new RoutingRuleEscalationPolicyAction()
.type(
RoutingRuleEscalationPolicyActionType
.ESCALATION_POLICY)
.policyId(ESCALATION_POLICY_DATA_ID)
.urgency(Urgency.LOW)
.ackTimeoutMinutes(30L)
.supportHours(
new RoutingRuleEscalationPolicyActionSupportHours()
.timeZone("Europe/Paris")
.restrictions(
Arrays.asList(
new TimeRestriction()
.endDay(
Weekday.WEDNESDAY)
.endTime("17:00:00")
.startDay(
Weekday.WEDNESDAY)
.startTime("09:00:00"),
new TimeRestriction()
.endDay(
Weekday.THURSDAY)
.endTime("17:00:00")
.startDay(
Weekday.THURSDAY)
.startTime(
"09:00:00")))))))
.query(
"tags.service:support_hours_and_acknowledgment_timeout"),
new TeamRoutingRulesRequestRule()
.policyId(ESCALATION_POLICY_DATA_ID)
.query("tags.service:legacy_policy_definition")
.urgency(Urgency.LOW),
new TeamRoutingRulesRequestRule()
.actions(
Collections.singletonList(
new RoutingRuleAction(
new RoutingRuleEscalationPolicyAction()
.type(
RoutingRuleEscalationPolicyActionType
.ESCALATION_POLICY)
.policyId(ESCALATION_POLICY_DATA_ID)
.urgency(Urgency.LOW))))
.query(""))))
.id(DD_TEAM_DATA_ID)
.type(TeamRoutingRulesRequestDataType.TEAM_ROUTING_RULES));
try {
TeamRoutingRules result =
apiInstance.setOnCallTeamRoutingRules(
DD_TEAM_DATA_ID,
body,
new SetOnCallTeamRoutingRulesOptionalParameters().include("rules"));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OnCallApi#setOnCallTeamRoutingRules");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Set On-Call team routing rules returns "OK" response
"""
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_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
from datadog_api_client.v2.model.team_routing_rules_request_data_type import TeamRoutingRulesRequestDataType
from datadog_api_client.v2.model.team_routing_rules_request_rule import TeamRoutingRulesRequestRule
from datadog_api_client.v2.model.time_restriction import TimeRestriction
from datadog_api_client.v2.model.time_restrictions import TimeRestrictions
from datadog_api_client.v2.model.urgency import Urgency
from datadog_api_client.v2.model.weekday import Weekday
# there is a valid "dd_team" in the system
DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"]
# there is a valid "escalation_policy" in the system
ESCALATION_POLICY_DATA_ID = environ["ESCALATION_POLICY_DATA_ID"]
body = TeamRoutingRulesRequest(
data=TeamRoutingRulesRequestData(
attributes=TeamRoutingRulesRequestDataAttributes(
rules=[
TeamRoutingRulesRequestRule(
actions=[
RoutingRuleEscalationPolicyAction(
type=RoutingRuleEscalationPolicyActionType.ESCALATION_POLICY,
policy_id=ESCALATION_POLICY_DATA_ID,
urgency=Urgency.LOW,
),
],
query="tags.service:time_restrictions",
time_restriction=TimeRestrictions(
time_zone="Europe/Paris",
restrictions=[
TimeRestriction(
end_day=Weekday.MONDAY,
end_time="17:00:00",
start_day=Weekday.MONDAY,
start_time="09:00:00",
),
TimeRestriction(
end_day=Weekday.TUESDAY,
end_time="17:00:00",
start_day=Weekday.TUESDAY,
start_time="09:00:00",
),
],
),
),
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="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,
type=TeamRoutingRulesRequestDataType.TEAM_ROUTING_RULES,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = OnCallApi(api_client)
response = api_instance.set_on_call_team_routing_rules(team_id=DD_TEAM_DATA_ID, include="rules", body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Set On-Call team routing rules returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::OnCallAPI.new
# there is a valid "dd_team" in the system
DD_TEAM_DATA_ID = ENV["DD_TEAM_DATA_ID"]
# there is a valid "escalation_policy" in the system
ESCALATION_POLICY_DATA_ID = ENV["ESCALATION_POLICY_DATA_ID"]
body = DatadogAPIClient::V2::TeamRoutingRulesRequest.new({
data: DatadogAPIClient::V2::TeamRoutingRulesRequestData.new({
attributes: DatadogAPIClient::V2::TeamRoutingRulesRequestDataAttributes.new({
rules: [
DatadogAPIClient::V2::TeamRoutingRulesRequestRule.new({
actions: [
DatadogAPIClient::V2::RoutingRuleEscalationPolicyAction.new({
type: DatadogAPIClient::V2::RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
policy_id: ESCALATION_POLICY_DATA_ID,
urgency: DatadogAPIClient::V2::Urgency::LOW,
}),
],
query: "tags.service:time_restrictions",
time_restriction: DatadogAPIClient::V2::TimeRestrictions.new({
time_zone: "Europe/Paris",
restrictions: [
DatadogAPIClient::V2::TimeRestriction.new({
end_day: DatadogAPIClient::V2::Weekday::MONDAY,
end_time: "17:00:00",
start_day: DatadogAPIClient::V2::Weekday::MONDAY,
start_time: "09:00:00",
}),
DatadogAPIClient::V2::TimeRestriction.new({
end_day: DatadogAPIClient::V2::Weekday::TUESDAY,
end_time: "17:00:00",
start_day: DatadogAPIClient::V2::Weekday::TUESDAY,
start_time: "09:00:00",
}),
],
}),
}),
DatadogAPIClient::V2::TeamRoutingRulesRequestRule.new({
actions: [
DatadogAPIClient::V2::RoutingRuleEscalationPolicyAction.new({
type: DatadogAPIClient::V2::RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
policy_id: ESCALATION_POLICY_DATA_ID,
urgency: DatadogAPIClient::V2::Urgency::LOW,
ack_timeout_minutes: 30,
support_hours: DatadogAPIClient::V2::RoutingRuleEscalationPolicyActionSupportHours.new({
time_zone: "Europe/Paris",
restrictions: [
DatadogAPIClient::V2::TimeRestriction.new({
end_day: DatadogAPIClient::V2::Weekday::WEDNESDAY,
end_time: "17:00:00",
start_day: DatadogAPIClient::V2::Weekday::WEDNESDAY,
start_time: "09:00:00",
}),
DatadogAPIClient::V2::TimeRestriction.new({
end_day: DatadogAPIClient::V2::Weekday::THURSDAY,
end_time: "17:00:00",
start_day: DatadogAPIClient::V2::Weekday::THURSDAY,
start_time: "09:00:00",
}),
],
}),
}),
],
query: "tags.service:support_hours_and_acknowledgment_timeout",
}),
DatadogAPIClient::V2::TeamRoutingRulesRequestRule.new({
policy_id: ESCALATION_POLICY_DATA_ID,
query: "tags.service:legacy_policy_definition",
urgency: DatadogAPIClient::V2::Urgency::LOW,
}),
DatadogAPIClient::V2::TeamRoutingRulesRequestRule.new({
actions: [
DatadogAPIClient::V2::RoutingRuleEscalationPolicyAction.new({
type: DatadogAPIClient::V2::RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
policy_id: ESCALATION_POLICY_DATA_ID,
urgency: DatadogAPIClient::V2::Urgency::LOW,
}),
],
query: "",
}),
],
}),
id: DD_TEAM_DATA_ID,
type: DatadogAPIClient::V2::TeamRoutingRulesRequestDataType::TEAM_ROUTING_RULES,
}),
})
opts = {
include: "rules",
}
p api_instance.set_on_call_team_routing_rules(DD_TEAM_DATA_ID, body, opts)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Set On-Call team routing rules returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_on_call::OnCallAPI;
use datadog_api_client::datadogV2::api_on_call::SetOnCallTeamRoutingRulesOptionalParams;
use datadog_api_client::datadogV2::model::RoutingRuleAction;
use datadog_api_client::datadogV2::model::RoutingRuleEscalationPolicyAction;
use datadog_api_client::datadogV2::model::RoutingRuleEscalationPolicyActionSupportHours;
use datadog_api_client::datadogV2::model::RoutingRuleEscalationPolicyActionType;
use datadog_api_client::datadogV2::model::TeamRoutingRulesRequest;
use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestData;
use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestDataAttributes;
use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestDataType;
use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestRule;
use datadog_api_client::datadogV2::model::TimeRestriction;
use datadog_api_client::datadogV2::model::TimeRestrictions;
use datadog_api_client::datadogV2::model::Urgency;
use datadog_api_client::datadogV2::model::Weekday;
#[tokio::main]
async fn main() {
// there is a valid "dd_team" in the system
let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap();
// there is a valid "escalation_policy" in the system
let escalation_policy_data_id = std::env::var("ESCALATION_POLICY_DATA_ID").unwrap();
let body = TeamRoutingRulesRequest::new().data(
TeamRoutingRulesRequestData::new(TeamRoutingRulesRequestDataType::TEAM_ROUTING_RULES)
.attributes(TeamRoutingRulesRequestDataAttributes::new().rules(vec![
TeamRoutingRulesRequestRule::new()
.actions(vec![RoutingRuleAction::RoutingRuleEscalationPolicyAction(
Box::new(
RoutingRuleEscalationPolicyAction::new(
escalation_policy_data_id.clone(),
RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
)
.urgency(Urgency::LOW),
),
)])
.query("tags.service:time_restrictions".to_string())
.time_restriction(TimeRestrictions::new(
vec![
TimeRestriction::new()
.end_day(Weekday::MONDAY)
.end_time("17:00:00".to_string())
.start_day(Weekday::MONDAY)
.start_time("09:00:00".to_string()),
TimeRestriction::new()
.end_day(Weekday::TUESDAY)
.end_time("17:00:00".to_string())
.start_day(Weekday::TUESDAY)
.start_time("09:00:00".to_string()),
],
"Europe/Paris".to_string(),
)),
TeamRoutingRulesRequestRule::new()
.actions(vec![RoutingRuleAction::RoutingRuleEscalationPolicyAction(
Box::new(
RoutingRuleEscalationPolicyAction::new(
escalation_policy_data_id.clone(),
RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
)
.ack_timeout_minutes(30)
.support_hours(
RoutingRuleEscalationPolicyActionSupportHours::new(
"Europe/Paris".to_string(),
)
.restrictions(vec![
TimeRestriction::new()
.end_day(Weekday::WEDNESDAY)
.end_time("17:00:00".to_string())
.start_day(Weekday::WEDNESDAY)
.start_time("09:00:00".to_string()),
TimeRestriction::new()
.end_day(Weekday::THURSDAY)
.end_time("17:00:00".to_string())
.start_day(Weekday::THURSDAY)
.start_time("09:00:00".to_string()),
]),
)
.urgency(Urgency::LOW),
),
)])
.query("tags.service:support_hours_and_acknowledgment_timeout".to_string()),
TeamRoutingRulesRequestRule::new()
.policy_id(escalation_policy_data_id.clone())
.query("tags.service:legacy_policy_definition".to_string())
.urgency(Urgency::LOW),
TeamRoutingRulesRequestRule::new()
.actions(vec![RoutingRuleAction::RoutingRuleEscalationPolicyAction(
Box::new(
RoutingRuleEscalationPolicyAction::new(
escalation_policy_data_id.clone(),
RoutingRuleEscalationPolicyActionType::ESCALATION_POLICY,
)
.urgency(Urgency::LOW),
),
)])
.query("".to_string()),
]))
.id(dd_team_data_id.clone()),
);
let configuration = datadog::Configuration::new();
let api = OnCallAPI::with_config(configuration);
let resp = api
.set_on_call_team_routing_rules(
dd_team_data_id.clone(),
body,
SetOnCallTeamRoutingRulesOptionalParams::default().include("rules".to_string()),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Set On-Call team routing rules returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.OnCallApi(configuration);
// there is a valid "dd_team" in the system
const DD_TEAM_DATA_ID = process.env.DD_TEAM_DATA_ID as string;
// there is a valid "escalation_policy" in the system
const ESCALATION_POLICY_DATA_ID = process.env
.ESCALATION_POLICY_DATA_ID as string;
const params: v2.OnCallApiSetOnCallTeamRoutingRulesRequest = {
body: {
data: {
attributes: {
rules: [
{
actions: [
{
type: "escalation_policy",
policyId: ESCALATION_POLICY_DATA_ID,
urgency: "low",
},
],
query: "tags.service:time_restrictions",
timeRestriction: {
timeZone: "Europe/Paris",
restrictions: [
{
endDay: "monday",
endTime: "17:00:00",
startDay: "monday",
startTime: "09:00:00",
},
{
endDay: "tuesday",
endTime: "17:00:00",
startDay: "tuesday",
startTime: "09:00:00",
},
],
},
},
{
actions: [
{
type: "escalation_policy",
policyId: ESCALATION_POLICY_DATA_ID,
urgency: "low",
ackTimeoutMinutes: 30,
supportHours: {
timeZone: "Europe/Paris",
restrictions: [
{
endDay: "wednesday",
endTime: "17:00:00",
startDay: "wednesday",
startTime: "09:00:00",
},
{
endDay: "thursday",
endTime: "17:00:00",
startDay: "thursday",
startTime: "09:00:00",
},
],
},
},
],
query: "tags.service:support_hours_and_acknowledgment_timeout",
},
{
policyId: ESCALATION_POLICY_DATA_ID,
query: "tags.service:legacy_policy_definition",
urgency: "low",
},
{
actions: [
{
type: "escalation_policy",
policyId: ESCALATION_POLICY_DATA_ID,
urgency: "low",
},
],
query: "",
},
],
},
id: DD_TEAM_DATA_ID,
type: "team_routing_rules",
},
},
teamId: DD_TEAM_DATA_ID,
include: "rules",
};
apiInstance
.setOnCallTeamRoutingRules(params)
.then((data: v2.TeamRoutingRules) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"