Metadata-Version: 2.4
Name: netsware-sdk
Version: 2.1.0
Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
Author: Netsware Systems LLP
License: MIT
Project-URL: Homepage, https://netsware.com
Project-URL: Documentation, https://netsware.com/dashboard/docs
Keywords: netsware,business-hours,scheduled-jobs,webhooks,cron
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# netsware-sdk

Official Python SDK for the [Netsware](https://netsware.com) API — Business Hours,
Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.

## Install

```bash
pip install netsware-sdk
```

## Quickstart

```python
from netsware import Netsware, verify_webhook

client = Netsware("nw_live_xxx")

# Is a business open right now?
status = client.hours.check(timezone="Asia/Kolkata", country="IN")
print(status["open"])

# Create a business-hours schedule
sched = client.hours.create_schedule(
    name="Mumbai office",
    days=["MON", "TUE", "WED", "THU", "FRI"],
    open_time="09:00",
    close_time="18:00",
    timezone="Asia/Kolkata",
    country="IN",
)

# Schedule a one-time job
job = client.jobs.schedule(
    name="Send reminder",
    url="https://example.com/webhook",
    run_at="2026-07-01T09:00:00",
    timezone="Asia/Kolkata",
    payload={"user_id": "123"},
)

# Register a webhook (one event per registration)
hook = client.webhooks.register(
    product="scheduled_jobs",
    event="job.completed",
    url="https://example.com/events",
)
```

## Verifying webhook signatures

Pass the **raw** request body string for a byte-exact check:

```python
ok = verify_webhook(
    payload=raw_body,                       # raw request body (string)
    signature=headers["X-Netsware-Signature"],
    timestamp=headers["X-Netsware-Timestamp"],
    secret="whsec_...",
)
if not ok:
    ...  # reject
```

## Groups, variables, runs & metrics

```python
# Organize jobs into groups
g = client.groups.create("Nightly")
client.groups.rename(g["id"], "Nightly batch")

# Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
client.variables.set("API_BASE_URL", "https://api.acme.io")
client.variables.set("API_TOKEN", "t0ken", is_secret=True)

# What's broken everywhere? (status is required; success has no account-wide feed)
failing = client.runs.list(status="failed", since="24h")

# Per-job history filtered by outcome (retention-clamped)
errs = client.jobs.logs(job["id"], status="failed")

# Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
m = client.metrics.get(window="30d")
print(m["totals"]["runs"], m["current"]["active_jobs"])
```

## Configuration

```python
client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
```

Full API reference: <https://netsware.com/dashboard/docs>.

MIT © Netsware Systems LLP
