Metadata-Version: 2.4
Name: scrubbe-sdk
Version: 1.0.1
Summary: Official Python SDK for the Scrubbe Operational Intelligence Platform
License: Proprietary
Keywords: scrubbe,incident,operations,observability,sdk,sse
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: mypy>=1.9; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"

# scrubbe-sdk — Python

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

## Installation

```sh
pip install scrubbe-sdk
```

## Quick start

```python
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

```python
# 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

```python
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

```python
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

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