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
- Clone the repository:
git clone <repository-url>
cd opsgenielib
- Sync dependencies (creates .venv automatically):
uv sync
- 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
- Build the package:
uv build
- Upload to PyPI:
uv publish
- 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:
- Update the version in
.VERSION - Update
HISTORY.mdwith changes - 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 runto 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 buildto build distributions - Test on TestPyPI before publishing to production PyPI
- Always update
HISTORY.mdbefore releasing - Tag releases with semantic versioning (vX.Y.Z)
Configuration Files
pyproject.toml- Project metadata and dependencies.VERSION- Current version numberpyproject.toml([tool.ruff]section) - Linting and formatting configurationtox.ini- Tox testing configurationuv.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
Metadata
Release files for opsgenielib 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| opsgenielib-0.1.1.tar.gz | 47.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opsgenielib-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.4 kB
Release files / opsgenielib-0.1.1.tar.gz
| Download URL | opsgenielib-0.1.1.tar.gz |
|---|---|
| Size | 47.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb3bb667793958e221f18986a110b770c210061aa23d179135a0d56e6895816b
|
|
BLAKE2b-256 checksum How to use checksums |
63e8ff96779c4fc280f5c98f2f490bd8f10bae018667e178e1cd469d81a7a38c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Release files / opsgenielib-0.1.1-py3-none-any.whl
| Download URL | opsgenielib-0.1.1-py3-none-any.whl |
|---|---|
| Size | 48.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a240d6d9e8ff8e02f7054ec82d28260ba7944748edcf3577c59d5d3ee2049f47
|
|
BLAKE2b-256 checksum How to use checksums |
375976d33735943a218f811439f36e13dabc0752b4e56a740422c033b1f564d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Security for opsgenielib 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.