Metadata-Version: 2.4
Name: pysophoscentral
Version: 0.2.0
Summary: Python client for the Sophos Central API
Author: Simone Dalla
Author-email: Simone Dalla <simodalla@gmail.com>
License-Expression: MIT
License-File: LICENSE
Requires-Dist: pydantic[email]>=2.7.1,<3
Requires-Dist: pydantic-settings>=2.2.1,<3
Requires-Dist: pydantic-settings-toml>=0.2.0,<0.3
Requires-Dist: requests>=2.31.0,<3
Requires-Dist: devtools>=0.12.2,<1
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# pysophoscentral

A Python client library for the [Sophos Central API](https://developer.sophos.com/).

> **Status: work in progress (pre-1.0).** The API surface is incomplete and may
> change between minor releases without notice. This release is published to
> reserve the package name; a stable 1.0 is on the roadmap.

## Features

- OAuth2 client-credentials authentication and tenant resolution (`whoami`)
- Endpoints: list, read, filter (Endpoint API v1)
- Directory users: list, read, create, update, delete (Common API v1)
- Alerts and account health check
- Typed request/response models built on Pydantic v2

## Requirements

- Python 3.12+

## Installation

```bash
pip install pysophoscentral
```

## Quickstart

Configuration is loaded from a TOML file:

```toml
# settings.toml
[sophos_central]
base_url = "https://api.central.sophos.com/"
auth_endpoint_url = "https://id.sophos.com/api/v2/oauth2/token"
auth_client_id = "<your-client-id>"
auth_client_secret = "<your-client-secret>"
api_version = "v1"
```

```python
from pysophoscentral.api import SophosCentralClient
from pysophoscentral.settings import AppSettings

settings = AppSettings(_env_file="settings.toml")
client = SophosCentralClient(settings.sophos_central)

client.authenticate()   # obtain the OAuth2 access token
client.read_whoami()    # resolve tenant id and data region (required)

endpoints = client.read_endpoints()
for endpoint in endpoints.items:
    print(endpoint.id, endpoint.hostname)
```

Note: `authenticate()` and `read_whoami()` must be called, in this order,
before any other API call.

## License

[MIT](LICENSE)
