Skip to main content

opsduty-python

Command-line utility for interfacing with OpsDuty.

The opsduty-python library is built with two core features in mind:

  • Command-line interface to interact with OpsDuty
  • Programmatic way to report heartbeat checkins in Python

Help

See the documentation for more details.

CLI

The opsduty-python package contains a CLI that can be used to interact with OpsDuty.

The preferred way to install the CLI is to use pipx install opsduty-python.

$ opsduty
Usage: opsduty [OPTIONS] COMMAND [ARGS]...

Options:
  --log-format [json|logfmt|console]
                                  [default: console]
  --log-level [error|warning|info|debug]
                                  [default: info]
  --base-url TEXT                 Base URL for API requests to OpsDuty.
  --timeout INTEGER               API request timeout to OpsDuty.  [required]
  --access-token TEXT             Set the bearer token used to communicate
                                  with OpsDuty.  [env var:
                                  OPSDUTY_ACCESS_TOKEN]
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Commands:
  heartbeats  Commands for managing and monitoring heartbeats.
  schedules   Commands for accessing schedules.

  Command-line utility for interfacing with OpsDuty.

Heartbeats

Send periodic heartbeats to OpsDuty using opsduty-python. The heartbeat needs to be configured in OpsDuty before check-ins can be observed. Head over to https://opsduty.io to configure your heartbeats.

Installation

Install using pip install -U opsduty-python.

Alternative 1: Decorator

from opsduty_python.heartbeats.heartbeats import (
    heartbeat_checkin,
)

@heartbeat_checkin(heartbeat="HBXXXX", environment="prod", enabled=True)
def periodic_job():
    pass

Alternative 2: Send heartbeat manually.

from opsduty_python.heartbeats.heartbeats import (
    send_heartbeat_checkin,
)

def periodic_job():
    try:
        pass
    except Exception:
        print("Job failed.")
    else:
        send_heartbeat_checkin(heartbeat="HBXXXX", environment="prod")

Metadata

Release files for opsduty-python 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opsduty-python 0.2.5
File Size Uploaded
opsduty_python-0.2.5.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opsduty-python 0.2.5
File Interpreter ABI Platform
opsduty_python-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.5 kB

Release files / opsduty_python-0.2.5.tar.gz

Download URL opsduty_python-0.2.5.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e5aaed30098f58f998cd7897a46ef7a46b1ec91faddf249be9fc6ef18b4650a2
BLAKE2b-256 checksum
How to use checksums
59537aa4b19fb7df08575b74e02f872c34da26e274324d42a46224385e70c960
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.3 Linux/6.17.0-1008-azure

Release files / opsduty_python-0.2.5-py3-none-any.whl

Download URL opsduty_python-0.2.5-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52acff537cfc3bf1d220db8ff406dc4d7f086cd0e202113dc121966ccfb018a3
BLAKE2b-256 checksum
How to use checksums
90cf1560438585e93faf7186649200e98d8476c44ad6a743b12b814918b4a64d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.3 Linux/6.17.0-1008-azure

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page