Skip to main content

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

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.

  1. In the navbar go to 'Integrations' > 'API Access Keys'
  2. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdscheduler-0.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdscheduler-0.2.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pdscheduler-0.2.0.tar.gz.

File metadata

  • Download URL: pdscheduler-0.2.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

Hashes for pdscheduler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5075dace0bf921f6b0ec6fc76663f71aac5f57841c190b77f72675e63434a61c
MD5 18960e9ca886b6776bbc4a528d5f5386
BLAKE2b-256 4661681fb70291b0d3b12c49bbb422a9190f2aab7db6767cb463c5911e26faf1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdscheduler-0.2.0.tar.gz:

Publisher: publish.yml on Raphaelvddoel/pdscheduler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdscheduler-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pdscheduler-0.2.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

Hashes for pdscheduler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7073d6d2837caaf45f6a2b184ad897c0dad639a0ce141c105ad2bd69698c11d
MD5 f2e3bba28dd0acaae0aec0c4b9f0afea
BLAKE2b-256 f50fae23add935455365b2a37650e8cbc55664f90270295eadf0fc476ca28b4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdscheduler-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Raphaelvddoel/pdscheduler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page