# What this PR does This PR: - adds a few attributes to paginated API responses - removes channel filter "send demo alert" internal API endpoint + tests (this endpoint was marked as deprecated + not consumed by the web UI) With the new paginated API response schema, the web UI will no longer need to: - hardcode `ITEMS_PER_PAGE` for each table - manually calculate total number of pages (these two things ☝️ will be done in https://github.com/grafana/oncall/issues/2476) For `GET /api/internal/v1/alertgroups` the response will now look like this: ```diff { "next": <url> | None, "previous": <url> | None, "results": [], ++ "page_size": <int> } ``` For all other paginated API responses, the response will now look like: ```diff { "count": <int>, "next": <url> | None, "previous": <url> | None, "results": [], ++ "page_size": <int>, ++ "current_page_number": <int>, ++ "total_pages": <int> } ``` ## TODO - [x] update public API docs to include these new attributes ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
7.5 KiB
7.5 KiB
| canonical | title | weight |
|---|---|---|
| https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_policies/ | Escalation Policies HTTP API | 300 |
Create an escalation policy
curl "{{API_URL}}/api/v1/escalation_policies/" \
--request POST \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json" \
--data '{
"escalation_chain_id": "F5JU6KJET33FE",
"type": "wait",
"duration": 60
}'
The above command returns JSON structured in the following way:
{
"id": "E3GA6SJETWWJS",
"escalation_chain_id": "F5JU6KJET33FE",
"position": 0,
"type": "wait",
"duration": 60
}
| Parameter | Required | Description |
|---|---|---|
escalation_chain_id |
Yes | Each escalation policy is assigned to a specific escalation chain. |
position |
Optional | Escalation policies execute one after another starting from position=0. Position=-1 will put the escalation policy to the end of the list. A new escalation policy created with a position of an existing escalation policy will move the old one (and all following) down in the list. |
type |
Yes | One of: wait, notify_persons, notify_person_next_each_time, notify_on_call_from_schedule, notify_user_group, trigger_action, resolve, notify_whole_channel, notify_if_time_from_to. |
duration |
Optional | The duration, in seconds, when type wait is chosen. |
important |
Optional | Default is false. Will assign "important" to personal notification rules if true. This can be used to distinguish alerts on which you want to be notified immediately by phone. Applicable for types notify_persons, notify_on_call_from_schedule, and notify_user_group. |
action_to_trigger |
If type = trigger_action |
ID of an action, or webhook. |
group_to_notify |
If type = notify_user_group |
ID of a User Group. |
persons_to_notify |
If type = notify_persons |
List of user IDs. |
persons_to_notify_next_each_time |
If type = notify_person_next_each_time |
List of user IDs. |
notify_on_call _from_schedule |
If type = notify_on_call_from_schedule |
ID of a Schedule. |
notify_if_time_from |
If type = notify_if_time_from_to |
UTC time represents the beginning of the time period, for example 09:00:00Z. |
notify_if_time_to |
If type = notify_if_time_from_to |
UTC time represents the end of the time period, for example 18:00:00Z. |
HTTP request
POST {{API_URL}}/api/v1/escalation_policies/
Get an escalation policy
curl "{{API_URL}}/api/v1/escalation_policies/E3GA6SJETWWJS/" \
--request GET \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json" \
The above command returns JSON structured in the following way:
{
"id": "E3GA6SJETWWJS",
"escalation_chain_id": "F5JU6KJET33FE",
"position": 0,
"type": "wait",
"duration": 60
}
HTTP request
GET {{API_URL}}/api/v1/escalation_policies/<ESCALATION_POLICY_ID>/
List escalation policies
curl "{{API_URL}}/api/v1/escalation_policies/" \
--request GET \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json"
The above command returns JSON structured in the following way:
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": "E3GA6SJETWWJS",
"escalation_chain_id": "F5JU6KJET33FE",
"position": 0,
"type": "wait",
"duration": 60
},
{
"id": "E5JJTU52M5YM4",
"escalation_chain_id": "F5JU6KJET33FE",
"position": 1,
"type": "notify_person_next_each_time",
"persons_to_notify_next_each_time": ["U4DNY931HHJS5"]
}
],
"current_page_number": 1,
"page_size": 50,
"total_pages": 1
}
The following available filter parameter should be provided as a GET argument:
escalation_chain_id
HTTP request
GET {{API_URL}}/api/v1/escalation_policies/
Delete an escalation policy
curl "{{API_URL}}/api/v1/escalation_policies/E3GA6SJETWWJS/" \
--request DELETE \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json"
HTTP request
DELETE {{API_URL}}/api/v1/escalation_policies/<ESCALATION_POLICY_ID>/