alure-sdk 0.2.0
Alure Python SDK for licensing and updates
License: MIT
Requires Python: >=3.10
Keywords: licensing, updates, sdk, alure

# Alure Python SDK

Official SDK for licensing + updates.

## Install (dev)
```bash
pip install -e .
```

## Install (PyPI)
```bash
pip install alure-sdk
```

Build and upload:
```bash
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
```

## Quickstart (EN)
```python
from alure_sdk import AlureClient

client = AlureClient(base_url="http://localhost:3000/api/v1")
result = client.ensure_active(license_key="YOUR-LICENSE-KEY")

if not result.get("valid"):
    raise SystemExit(f"License invalid: {result.get('reason')}")

modules = result.get("modules") or []
modules_full = result.get("modules_full") or []
print("Modules:", modules or "none")
print("Modules full:", modules_full)
```

Helpful methods:
- `ensure_active(...)`: activates if missing, otherwise verifies (online/offline).
- `enabled_modules()`: returns active module keys from the stored receipt.
- `verify_online()` / `verify_offline()` for explicit control.
- `quickstart(...)`: shortcut that returns modules + validation result.
- `check_update_and_download(...)`: checks updates and downloads the asset.

## SDK Guide (EN)
### 1) Initialize client
```python
from alure_sdk import AlureClient, FileStorage
from pathlib import Path

storage_dir = Path.home() / ".alure-client"
client = AlureClient(
    base_url="http://localhost:3000/api/v1",
    storage=FileStorage(storage_dir),
)
```

### 2) Activate or verify
```python
result = client.ensure_active(license_key="ALR-XXXX-YYYY-ZZZZ")
if not result.get("valid"):
    raise RuntimeError(result.get("reason"))
```

### 3) Use modules
```python
modules = client.enabled_modules()
if "pro_feature" in modules:
    print("Pro feature enabled")
```

### 4) Check updates
```python
update = client.check_update(project_id="PROJECT_ID", channel="stable")
if update.get("update_available"):
    asset = update.get("asset")
    if asset:
        client.download_asset(asset["asset_id"])
```

### 5) One-liner (quickstart)
```python
result = client.quickstart(license_key="ALR-XXXX-YYYY-ZZZZ")
print(result.get("modules"))
print(result.get("modules_full"))
```

Notes:
- `ensure_active()` stores/refreshes the receipt automatically.
- Online verify may return `new_receipt`; the SDK saves it for you.
- Use `verify_offline(..., verify_signature=True)` if you ship the public key.

---

# SDK Python (IT)

SDK ufficiale per licensing + update.

## Installazione (dev)
```bash
pip install -e .
```

## Installazione (PyPI)
```bash
pip install alure-sdk
```

Build e upload:
```bash
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
```

## Uso rapido (IT)
```python
from alure_sdk import AlureClient

client = AlureClient(base_url="http://localhost:3000/api/v1")
result = client.ensure_active(license_key="YOUR-LICENSE-KEY")

if not result.get("valid"):
    raise SystemExit(f"Licenza non valida: {result.get('reason')}")

modules = result.get("modules") or []
modules_full = result.get("modules_full") or []
print("Moduli:", modules or "nessuno")
print("Moduli completi:", modules_full)
```

Metodi utili:
- `ensure_active(...)`: attiva se manca, altrimenti verifica (online/offline).
- `enabled_modules()`: ritorna le chiavi dei moduli attivi dal receipt.
- `verify_online()` / `verify_offline()` per controllo avanzato.
- `quickstart(...)`: scorciatoia con moduli + validazione.
- `check_update_and_download(...)`: verifica update e scarica asset.

## Guida SDK (IT)
### 1) Inizializzare il client
```python
from alure_sdk import AlureClient, FileStorage
from pathlib import Path

storage_dir = Path.home() / ".alure-client"
client = AlureClient(
    base_url="http://localhost:3000/api/v1",
    storage=FileStorage(storage_dir),
)
```

### 2) Attivare o verificare
```python
result = client.ensure_active(license_key="ALR-XXXX-YYYY-ZZZZ")
if not result.get("valid"):
    raise RuntimeError(result.get("reason"))
```

### 3) Moduli
```python
modules = client.enabled_modules()
if "pro_feature" in modules:
    print("Funzione Pro attiva")
```

### 4) Aggiornamenti
```python
update = client.check_update(project_id="PROJECT_ID", channel="stable")
if update.get("update_available"):
    asset = update.get("asset")
    if asset:
        client.download_asset(asset["asset_id"])
```

### 5) One-liner (quickstart)
```python
result = client.quickstart(license_key="ALR-XXXX-YYYY-ZZZZ")
print(result.get("modules"))
print(result.get("modules_full"))
```

Note:
- `ensure_active()` salva/aggiorna automaticamente il receipt.
- La verify online può restituire `new_receipt`; l'SDK lo salva.
- Usa `verify_offline(..., verify_signature=True)` se distribuisci la public key.