Skip to main content

A python library for Opsgenie

Project description

opsgenielib

A Python library for interacting with the Opsgenie API.

Documentation: https://opsgenielib.readthedocs.org/en/latest

Installation

Install from PyPI:

pip install opsgenielib

Or install from source:

git clone https://github.com/yourusername/opsgenielib.git
cd opsgenielib
pip install .

Usage

from opsgenielib import Opsgenie

# Initialize with your API key
opsgenie = Opsgenie(api_key='your-api-key')

# List teams
teams = opsgenie.list_teams()

# Get alerts
alerts = opsgenie.query_alerts('status: open')

# Create an alert
opsgenie.create_alert(
    message='Server is down',
    description='Production server not responding',
    priority='P1'
)

Development Setup

This project uses uv for fast, reliable Python package management.

Prerequisites

Install uv:

# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# Or via pip
pip install uv

Getting Started

  1. Clone the repository:
git clone <repository-url>
cd opsgenielib
  1. Sync dependencies (creates .venv automatically):
uv sync
  1. Activate the virtual environment:
# macOS/Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate

Development Workflow

Running Tests

Run tests with pytest:

uv run pytest

Run tests with coverage:

uv run pytest --cov=opsgenielib --cov-report=html --cov-report=term

Run tox for multi-version testing:

uv run tox

Linting

Run ruff for fast, comprehensive linting:

uv run ruff check opsgenielib

Format code with ruff:

uv run ruff format opsgenielib

The linting configuration is in pyproject.toml under [tool.ruff].

Building the Package

Build source and wheel distributions:

uv build

This creates distributions in the dist/ directory.

Publishing to PyPI

  1. Build the package:
uv build
  1. Upload to PyPI:
uv publish
  1. Or upload to TestPyPI first:
uv publish --publish-url https://test.pypi.org/legacy/

Note: You can set credentials via environment variables UV_PUBLISH_USERNAME and UV_PUBLISH_PASSWORD, or use UV_PUBLISH_TOKEN for token-based authentication.

Version Management

Version is stored in the .VERSION file. To bump the version:

  1. Update the version in .VERSION
  2. Update HISTORY.md with changes
  3. Commit and tag:
git add .VERSION HISTORY.md
git commit -m "Bump version to X.Y.Z"
git tag vX.Y.Z
git push origin main --tags

Generating Documentation

Build documentation with Sphinx:

cd docs
uv run sphinx-build -b html . _build/html

View the documentation by opening docs/_build/html/index.html.

Adding Dependencies

Add a runtime dependency:

uv add package-name

Add a development dependency:

uv add --dev package-name

Remove a dependency:

uv remove package-name

Lock dependencies after changes:

uv lock

Best Practices

Development

  • Always use uv run to execute commands in the project environment
  • Run tests before committing: uv run pytest
  • Run linting before committing: uv run ruff check opsgenielib
  • Format code before committing: uv run ruff format opsgenielib
  • Keep dependencies up to date: uv lock --upgrade

Building and Publishing

  • Use uv build to build distributions
  • Test on TestPyPI before publishing to production PyPI
  • Always update HISTORY.md before releasing
  • Tag releases with semantic versioning (vX.Y.Z)

Configuration Files

  • pyproject.toml - Project metadata and dependencies
  • .VERSION - Current version number
  • pyproject.toml ([tool.ruff] section) - Linting and formatting configuration
  • tox.ini - Tox testing configuration
  • uv.lock - Locked dependency versions (auto-generated)

Quick Reference

Common commands:

# Setup
uv sync                          # Install dependencies

# Development
uv run pytest                     # Run tests
uv run ruff check opsgenielib     # Lint code
uv run ruff format opsgenielib    # Format code
uv run pytest --cov=opsgenielib   # Run tests with coverage

# Dependencies
uv add requests                  # Add dependency
uv add --dev pytest              # Add dev dependency
uv lock                          # Update lockfile

# Building
uv build                         # Build package

# Publishing
uv publish                       # Upload to PyPI

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

MIT License - see LICENSE file for details.

Credits

Development Lead: Yorick Hoorneman yhoorneman@schubergphilis.com

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

opsgenielib-0.1.1.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

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

opsgenielib-0.1.1-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file opsgenielib-0.1.1.tar.gz.

File metadata

  • Download URL: opsgenielib-0.1.1.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for opsgenielib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fb3bb667793958e221f18986a110b770c210061aa23d179135a0d56e6895816b
MD5 a802e70910f31b0a0003214cf118679f
BLAKE2b-256 63e8ff96779c4fc280f5c98f2f490bd8f10bae018667e178e1cd469d81a7a38c

See more details on using hashes here.

File details

Details for the file opsgenielib-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for opsgenielib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a240d6d9e8ff8e02f7054ec82d28260ba7944748edcf3577c59d5d3ee2049f47
MD5 14e5a578feef8c967309c2ae35c9b30e
BLAKE2b-256 375976d33735943a218f811439f36e13dabc0752b4e56a740422c033b1f564d7

See more details on using hashes here.

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