Automatically schedule and upload on-call rotations to PagerDuty from a CSV file
Project description
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
Still has to be implemented
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.scheduler 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.
Thank you to the original author(s) for their contributions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdscheduler-0.1.0.tar.gz.
File metadata
- Download URL: pdscheduler-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a92c840cde18b14907546508fbe017ee6590ad4385be4d38b16c9fb020663fb4
|
|
| MD5 |
e9cab24a310c94c7889964773d456bdf
|
|
| BLAKE2b-256 |
95f84cda1ff92f49bd1d7193da32e83f54830e3a12b09a65e93ca983022d8f3a
|
Provenance
The following attestation bundles were made for pdscheduler-0.1.0.tar.gz:
Publisher:
publish.yml on Raphaelvddoel/pdscheduler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdscheduler-0.1.0.tar.gz -
Subject digest:
a92c840cde18b14907546508fbe017ee6590ad4385be4d38b16c9fb020663fb4 - Sigstore transparency entry: 189801675
- Sigstore integration time:
-
Permalink:
Raphaelvddoel/pdscheduler@2b3e3fc01f25df7b4995b7b713851b0b32e8d7cc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Raphaelvddoel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b3e3fc01f25df7b4995b7b713851b0b32e8d7cc -
Trigger Event:
release
-
Statement type:
File details
Details for the file pdscheduler-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdscheduler-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb0047a66d202df25f709ffaf07799811f284e1cad26b93664dae54eff720bed
|
|
| MD5 |
61de70bd9b33b09c047824b71a8f5dc7
|
|
| BLAKE2b-256 |
618bd8ccbcc4385b4cce2396bf97aaffda418fec08038404ff4d6f74b4e6ffac
|
Provenance
The following attestation bundles were made for pdscheduler-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Raphaelvddoel/pdscheduler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdscheduler-0.1.0-py3-none-any.whl -
Subject digest:
eb0047a66d202df25f709ffaf07799811f284e1cad26b93664dae54eff720bed - Sigstore transparency entry: 189801676
- Sigstore integration time:
-
Permalink:
Raphaelvddoel/pdscheduler@2b3e3fc01f25df7b4995b7b713851b0b32e8d7cc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Raphaelvddoel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b3e3fc01f25df7b4995b7b713851b0b32e8d7cc -
Trigger Event:
release
-
Statement type: