Skip to main content

Official Python SDK for the Scrubbe Operational Intelligence Platform

Project description

scrubbe-sdk — Python

Official async Python SDK for the Scrubbe Operational Intelligence Platform. Requires Python ≥ 3.10 and httpx.

Installation

pip install scrubbe-sdk

Quick start

import asyncio
from scrubbe import Scrubbe

async def main():
    async with Scrubbe(api_key="sk-...") as client:
        # Create an incident
        incident = await client.incident.create(
            title="Payment gateway degraded",
            priority="P1",
            service="payment-api",
        )
        print(incident["incident_id"])  # SI-000042

        # List all open incidents (lazy pagination)
        async for inc in client.incident.list(state="INVESTIGATING"):
            print(inc["title"])

        # Stream live events
        async for event in client.incident.subscribe(incident["incident_id"]):
            print(event["type"], event["data"])

asyncio.run(main())

Authentication

# 1. API key
client = Scrubbe(api_key="sk-...")

# 2. OAuth2
client = Scrubbe(client_id="...", client_secret="...")

# 3. Env vars: SCRUBBE_API_KEY or SCRUBBE_CLIENT_ID + SCRUBBE_CLIENT_SECRET
client = Scrubbe()

# 4. Credentials file ~/.scrubbe/credentials
# { "production": { "api_key": "sk-..." } }
client = Scrubbe(profile="production")

Configuration

from scrubbe import Scrubbe
from scrubbe.utils.retry import RetryOptions

client = Scrubbe(
    api_key="...",
    base_url="https://api.scrubbe.com",
    connect_timeout_ms=5_000,
    read_timeout_ms=30_000,
    retry=RetryOptions(max_attempts=3, base_delay_ms=500, max_delay_ms=30_000),
)

Error handling

from scrubbe import (
    GovernanceApprovalRequiredError,
    RateLimitedError,
    UnauthenticatedError,
)

try:
    await client.playbook.run("PB-0001", incident_id="SI-000042")
except GovernanceApprovalRequiredError as e:
    print("Pending approval:", e.approval_id)
except RateLimitedError as e:
    print(f"Retry after {e.retry_after}s")
except UnauthenticatedError:
    print("Check your API key")

Development

pip install -e ".[dev]"
ruff check src/ tests/          # lint
ruff format --check src/ tests/ # format check
mypy src/scrubbe                 # type check
pytest                           # tests + coverage

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

scrubbe_sdk-1.0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

scrubbe_sdk-1.0.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file scrubbe_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: scrubbe_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for scrubbe_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 77845fc7663287b39bffdfa983e1ee21be633910b66d33a54049e85746109383
MD5 666427279849553fe98ddda79eedc9b0
BLAKE2b-256 d4c9bf88e871a6b7fa33f7a87833f5af018e9ad1b7678233583c7c54ea7637e4

See more details on using hashes here.

File details

Details for the file scrubbe_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: scrubbe_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for scrubbe_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c856c5e1d956b8d9e15511c7f6f54fcff7740e8a3fcbf138883ae0d7d3aeb7b1
MD5 90810cfcdceacd9865eb59f8f6038962
BLAKE2b-256 3fedea2b49a03a25eca7b0225e4b4752d3ab732725d76323c97f2ed899f41952

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