Metadata-Version: 2.5
Name: solidping
Version: 0.1.0
Summary: Official Python SDK for SolidPing
Project-URL: Homepage, https://www.solidping.io
Project-URL: Repository, https://github.com/fclairamb/solidping-python
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.14
Requires-Dist: httpx>=0.28
Description-Content-Type: text/markdown

# SolidPing Python SDK

Official Python SDK for [SolidPing](https://www.solidping.io): manage checks, incidents and status
pages from Python without writing HTTP calls.

Work in progress, not published yet. The target is described in
[fclairamb/solidping#1117](https://github.com/fclairamb/solidping/issues/1117).

## Install

```bash
pip install solidping
```

Python 3.14 or later. The only dependency is `httpx`; the client is synchronous.

## Quickstart

Create a personal access token in SolidPing and export it:

```bash
export SOLIDPING_TOKEN=pat_...
export SOLIDPING_ORG=acme
```

```python
from solidping import SolidPing

sp = SolidPing()  # reads SOLIDPING_URL, SOLIDPING_ORG, SOLIDPING_TOKEN

# Create a check
check = sp.checks.create(name="Website", config={"url": "https://acme.com"})
print(check.slug, check.status)

# List the checks that are down
for check in sp.checks.list(status="down"):
    print(check.name)

# Acknowledge every open incident
for incident in sp.incidents.list(state="active"):
    sp.incidents.acknowledge(incident.uid)
```

## Configuration

Each setting is an argument of `SolidPing(...)` or an environment variable:

| Argument      | Environment       | Default               |
|---------------|-------------------|-----------------------|
| `url`         | `SOLIDPING_URL`   | `https://solidping.io` |
| `org`         | `SOLIDPING_ORG`   | required              |
| `token`       | `SOLIDPING_TOKEN` | required              |
| `timeout`     |                   | 30 (seconds)          |
| `max_retries` |                   | 2                     |

The client is also a context manager (`with SolidPing() as sp:`) and has a `close()` method.

## Resources

`sp.checks`, `sp.incidents`, `sp.status_pages`, `sp.maintenance_windows` and `sp.channels`.
Their methods are `list`, `get`, `create`, `update` and `delete` where the API has them, plus the
actions of the resource: `sp.checks.run_now(id)`, `sp.incidents.acknowledge(id)`,
`unacknowledge`, `snooze`, `unsnooze` and `resolve`.

Arguments are the API field names, unchanged (`sp.checks.create(name=..., config=...)`), and the
organization is never an argument. Results are objects with the API field names as attributes
and a `to_dict()` method. `list` returns an iterator that follows the pagination cursor for you.
A field the SDK does not know yet is kept (`to_dict()` returns it, and it is readable as an
attribute), and an unknown enum value, such as a plugin check type, is accepted.

## Errors

```python
import solidping
from solidping import SolidPing

sp = SolidPing(url="https://solidping.acme.com", org="acme", token="...", timeout=10, max_retries=0)

try:
    sp.checks.get("missing")
except solidping.NotFoundError:
    print("no such check")
except solidping.APIError as e:
    print(e.status, e.code, e.title, e.detail)
```

Everything the SDK raises is a `SolidPingError`. An `APIError` carries `status`, `code`, `title`,
`detail` and `fields` (the invalid fields of a validation error). The subclasses are
`AuthenticationError` (401), `PermissionDeniedError` (403), `NotFoundError` (404),
`ValidationError` (400, 422), `ConflictError` (409) and `RateLimitError` (429). A status without
a subclass is a plain `APIError`, whatever its `code`. `APIConnectionError` means the server
could not be reached, `APITimeoutError` (a subclass of it) that it did not answer in time.

## Retries and timeout

Connection errors, timeouts, 429 and 5xx are retried twice with exponential backoff and jitter. A
429 waits for its `Retry-After`. A `POST` is retried only on 429, because the API has no
idempotency key. `max_retries=0` disables the retries. The timeout is 30 seconds by default.

## Endpoints the SDK does not cover

```python
regions = sp.request("GET", "/api/v1/orgs/acme/regions")
```

`request(method, path, body=None, params=None)` uses the same auth, retries and errors, and returns
the decoded JSON.

## Debugging

`SOLIDPING_LOG=debug` logs each request and its response status on stderr (through the
`solidping` logger). The token is never logged.

## Development

See [AGENTS.md](AGENTS.md).

## License

MIT
