Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use oncall API #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dshack
Copy link
Contributor

@dshack dshack commented May 11, 2014

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"
}
}

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"
}
}
```
Now you can pass in an array of EPs in your secrets.json:

```
    "escalation_policies": {
        "policy1": "blksdhfs",
        "policy2:" "kjhsldfkjhsd"
    }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant