thegreenrobot / pagerduty_dashing

A Dashing dashboard for PagerDuty Services & Schedules
MIT License
44 stars 23 forks source link

Update to use oncall API #8

Open dshack opened 10 years ago

dshack commented 10 years ago

PagerDuty has a special-purpose API to return who is currently on-call for an escalation policy:

https://pdt-circular.pagerduty.com/api/v1/escalation_policies/on_call

It's not documented, but you can also stick an EP parameter in there, IE

https://pdt-circular.pagerduty.com/api/v1/escalation_policies/123456/on_call

There's some logic I need to fix as far as primary vs. secondary goes. Right now, it just returns the first two user entries in the 'user' blob, when what it should actually do is return the first user with level=1, and then the first user with level=2. Or, to get fancier, it should actually return all users on a given level.

"on_call":[
{
"level":1,
"start":"2014-05-11T07:00:00Z",
"end":"2014-05-12T07:00:00Z",
"user":{
"id":"P7QCNF1",
"name":"Amy Chantasirivisal",
"email":"amy@pagerduty.com",
"time_zone":"Pacific Time (US & Canada)",
"color":"turquoise"
}
},
{
"level":1,
"start":null,
"end":null,
"user":{
"id":"PYUUVV3",
"name":"Test 1",
"email":"test@example.com",
"time_zone":"Pacific Time (US & Canada)",
"color":"orange-red"
}
},
{
"level":1,
"start":"2014-03-06T08:00:00Z",
"end":"2015-05-08T23:13:24Z",
"user":{
"id":"PPFTW3L",
"name":"Jobs",
"email":"dave+jobs@pagerduty.com",
"time_zone":"Pacific Time (US & Canada)",
"color":"teal"
}
},
{
"level":2,
"start":null,
"end":null,
"user":{
"id":"PYUUVV3",
"name":"Test 1",
"email":"test@example.com",
"time_zone":"Pacific Time (US & Canada)",
"color":"orange-red"
}
},
{
"level":2,
"start":"2014-03-02T02:22:00Z",
"end":"2015-05-08T23:13:25Z",
"user":{
"id":"PVYIT4B",
"name":"Manisha Koirala (India)",
"email":"india@example.com",
"time_zone":"Pacific Time (US & Canada)",
"color":"dark-slate-blue"
}
}