Skip to content

Instantly share code, notes, and snippets.

@lost-theory
Created December 19, 2013 01:32
Show Gist options
  • Save lost-theory/8032849 to your computer and use it in GitHub Desktop.
Save lost-theory/8032849 to your computer and use it in GitHub Desktop.
how to show the name of the person on-call right now for a pagerduty schedule
import pygerduty
from datetime import datetime as dt, timedelta as d
p = pygerduty.PagerDuty("user-goes-here", "api-key-goes-here")
sched = p.schedules.show('SCHEDULEID')
t0 = dt.now()
t1 = t0 + d(minutes=1)
result = sched.entries.list(since=t0.strftime("%F %T"), until=t1.strftime("%F %T"))
print result[0].user.name if result else "nobody?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment