PDscheduler
Automatically schedule and upload on-call rotations to PagerDuty from a CSV file.
Overview
PDscheduler is a Python library designed to simplify the process of generating and uploading on-call schedules to PagerDuty. By providing a CSV file with your team's rotation details, the package will automatically create or update the schedule for the upcoming week.
Why only one week?
Due to limitations in the PagerDuty scheduling API, the schedule can only accommodate weekdays (e.g., "Wednesday"). This means that if you are available on a Wednesday this week but not on the same weekday next week, the API will not be able to handle that variation. As a result, the tool supports generating a schedule for only the next week.
Installation
Method 1: pip
pip install pdscheduler
Method 2: Clone the repo
git clone https://github.com/Raphaelvddoel/pdscheduler.git
cd pdscheduler
pip install -r requirements
Usage
Step 1: Generate csv file
Generate a csv file with the following structure
user_email,week_day,start_time,end_time
- user_email: The email address of the team member.
- week_day: The day of the week (e.g., monday, tuesday, etc.).
- start_time: The start time of the on-call shift (in 24-hour format, e.g.,
14:00). - end_time: The end time of the on-call shift (in 24-hour format, e.g.,
22:00).
Example csv
user_email,week_day,start_time,end_time
john.doe@example.com,monday,00:00,08:00
jane.smith@example.com,monday,08:00,16:00
alex.jones@example.com,tuesday,00:00,08:00
Step 2: Get PagerDuty API key
To use PDscheduler, you will need an API access key.
- In the navbar go to 'Integrations' > 'API Access Keys'
- Generate a new API key or use an existing one.
Step 3: Configure and run the script
Here's an example of how to use PDscheduler
from pdscheduler import PagerDutyScheduler
# Initialize the scheduler with your PagerDuty API key
scheduler = PagerDutyScheduler("your-api-key-here")
# Set the name, description, and timezone for the schedule
scheduler.set_name("Automatic Schedule")
scheduler.set_description("This schedule is generated automatically by pdscheduler.")
scheduler.set_timezone("Europe/Amsterdam")
# Set which days of the week and hours to include in the schedule
scheduler.set_days_of_week(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"])
scheduler.set_hours_of_day(9, 22)
# Set the users and exclude specific users from the schedule
scheduler.set_users_from_pager_duty()
scheduler.exclude_users_from_schedule(["excluded_user_id"])
# Set the location of your CSV file
scheduler.set_csv_file_location("test_data.csv")
# Generate and upload the schedule to PagerDuty
scheduler.generate_schedule()
scheduler.create_or_update_schedule()
For more information see example.py.
License
Distributed under the MIT License. See License for more information.
Acknowledgments
This project is based on the work done by skrypka/pdscheduling.
Metadata
Release files for PDscheduler 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pdscheduler-0.2.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdscheduler-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / pdscheduler-0.2.0.tar.gz
| Download URL | pdscheduler-0.2.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5075dace0bf921f6b0ec6fc76663f71aac5f57841c190b77f72675e63434a61c
|
|
BLAKE2b-256 checksum How to use checksums |
4661681fb70291b0d3b12c49bbb422a9190f2aab7db6767cb463c5911e26faf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 29, 2025.
Transparency logRelease files / pdscheduler-0.2.0-py3-none-any.whl
| Download URL | pdscheduler-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7073d6d2837caaf45f6a2b184ad897c0dad639a0ce141c105ad2bd69698c11d
|
|
BLAKE2b-256 checksum How to use checksums |
f50fae23add935455365b2a37650e8cbc55664f90270295eadf0fc476ca28b4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 29, 2025.
Transparency log