Python SDK for the Dominus Orchestrator Platform
Project description
CB Dominus SDK
Python SDK for the Dominus Orchestrator Platform
A unified, async-first Python SDK providing seamless access to all Dominus backend services including secrets management, database operations, caching, file storage, authentication, schema management, and structured logging.
Features
- Namespace-based API - Intuitive access via
dominus.db,dominus.redis,dominus.files, etc. - Async/Await - Built for modern async Python applications
- Automatic JWT Management - Token minting, caching, and refresh handled transparently
- Resilience Built-in - Circuit breaker, exponential backoff, and retry logic
- Typed Errors - Specific error classes for different failure modes
- Secure by Default - Client-side password hashing, encrypted cache, audit trail support
Quick Start
from dominus import dominus
# Set your token (or use DOMINUS_TOKEN environment variable)
import os
os.environ["DOMINUS_TOKEN"] = "your-psk-token"
# Start using the SDK
async def main():
# Secrets
db_url = await dominus.get("DATABASE_URL")
# Database queries
users = await dominus.db.query("users", filters={"status": "active"})
# Redis caching
await dominus.redis.set("session:123", {"user": "john"}, ttl=3600)
# File storage
result = await dominus.files.upload(data, "report.pdf", category="reports")
# Structured logging
await dominus.logs.info("User logged in", {"user_id": "123"})
Installation
# Clone or add as submodule
git clone https://github.com/carebridgesystems/cb-dominus-sdk.git
# Install dependencies
pip install httpx bcrypt cryptography
Namespaces
| Namespace | Service | Purpose |
|---|---|---|
dominus.secrets |
Warden | Secrets management |
dominus.db |
Scribe | Database CRUD operations |
dominus.redis |
Whisperer | Redis caching |
dominus.files |
Archivist | Object storage (B2) |
dominus.auth |
Guardian | Authentication & authorization |
dominus.ddl |
Smith | Schema DDL & migrations |
dominus.logs |
Herald | Structured logging |
dominus.portal |
Portal | User auth & sessions |
dominus.courier |
Courier | Email delivery (Postmark) |
dominus.open |
Scribe | Direct database access |
dominus.health |
Health | Service health checks |
Usage Examples
Secrets Management
# Root-level shortcuts
value = await dominus.get("API_KEY")
await dominus.upsert("API_KEY", "new-value", comment="Updated API key")
# Full namespace
secrets = await dominus.secrets.list(prefix="DB_")
await dominus.secrets.delete("OLD_KEY")
Database Operations
# Query with filters and pagination
users = await dominus.db.query(
"users",
filters={"status": "active", "role": ["admin", "manager"]},
sort_by="created_at",
sort_order="desc",
limit=50,
offset=0
)
# Insert
user = await dominus.db.insert("users", {
"email": "john@example.com",
"name": "John Doe"
})
# Update
await dominus.db.update("users", {"status": "inactive"}, filters={"id": user_id})
# Secure table access (requires audit reason)
patients = await dominus.db.query(
"patients",
schema="tenant_acme",
reason="Reviewing records for appointment #123",
actor="dr.smith"
)
Redis Caching
# Key-value operations
await dominus.redis.set("user:123", {"name": "John"}, ttl=3600)
value = await dominus.redis.get("user:123")
# Distributed locks
if await dominus.redis.setnx("lock:job", "worker-1", ttl=60):
try:
# Do exclusive work
pass
finally:
await dominus.redis.delete("lock:job")
# Counters
await dominus.redis.incr("page:views", delta=1)
# Hash operations
await dominus.redis.hset("user:123", "email", "john@example.com", ttl=3600)
File Storage
# Upload file
with open("report.pdf", "rb") as f:
result = await dominus.files.upload(
data=f.read(),
filename="report.pdf",
category="reports"
)
# Get download URL
download = await dominus.files.download(file_id=result["id"])
url = download["download_url"]
# List files
files = await dominus.files.list(category="reports", prefix="2025/")
Structured Logging
# Simple logging (auto-captures file and function)
await dominus.logs.info("User logged in", {"user_id": "123"})
await dominus.logs.error("Payment failed", {"order_id": "456"})
# With exception context
try:
risky_operation()
except Exception as e:
await dominus.logs.error("Operation failed", exception=e)
# Query logs
errors = await dominus.logs.query(level="error", limit=100)
Authentication
# User management
user = await dominus.auth.add_user(
username="john",
password="secure-password",
email="john@example.com"
)
# Role management
role = await dominus.auth.add_role(
name="Editor",
scope_slugs=["read", "write", "publish"]
)
# JWT operations
jwt = await dominus.auth.mint_jwt(user_id=user["id"], expires_in=900)
claims = await dominus.auth.validate_jwt(token)
Schema Management
# Create table
await dominus.ddl.add_table("orders", [
{"name": "id", "type": "UUID", "constraints": ["PRIMARY KEY"]},
{"name": "user_id", "type": "UUID", "constraints": ["NOT NULL"]},
{"name": "total", "type": "DECIMAL(10,2)"},
{"name": "created_at", "type": "TIMESTAMPTZ", "default": "NOW()"}
])
# Provision tenant schema
await dominus.ddl.provision_tenant("customer_acme", category_slug="healthcare")
User Authentication (Portal)
# User login
session = await dominus.portal.login(
username="john@example.com",
password="secret123",
tenant_id="tenant-uuid"
)
# Get current user
me = await dominus.portal.me()
# Get navigation (access-filtered)
nav = await dominus.portal.get_navigation()
# Profile & preferences
await dominus.portal.update_preferences(theme="dark", timezone="America/New_York")
# Logout
await dominus.portal.logout()
Email Delivery (Courier)
# Send email via Postmark template
result = await dominus.courier.send(
template_alias="welcome",
to="user@example.com",
from_email="noreply@myapp.com",
model={"name": "John", "product_name": "My App"}
)
# Convenience methods
await dominus.courier.send_password_reset(
to="user@example.com",
from_email="noreply@myapp.com",
name="John",
reset_url="https://myapp.com/reset?token=abc",
product_name="My App"
)
Error Handling
from dominus import (
dominus,
DominusError,
AuthenticationError,
AuthorizationError,
NotFoundError,
ValidationError,
SecureTableError,
)
try:
user = await dominus.auth.get_user(user_id="invalid")
except NotFoundError as e:
print(f"User not found: {e.message}")
except SecureTableError as e:
print("Secure table requires 'reason' and 'actor' parameters")
except DominusError as e:
print(f"Error {e.status_code}: {e.message}")
if e.details:
print(f"Details: {e.details}")
Error Types
| Error | Status | Description |
|---|---|---|
AuthenticationError |
401 | Invalid or missing token |
AuthorizationError |
403 | Insufficient permissions |
NotFoundError |
404 | Resource not found |
ValidationError |
400 | Invalid request data |
ConflictError |
409 | Duplicate or version conflict |
ServiceError |
5xx | Backend service error |
SecureTableError |
403 | Missing reason for secure table |
ConnectionError |
- | Network connection failed |
TimeoutError |
504 | Request timed out |
Configuration
Environment Variables
# Required: PSK token for authentication
export DOMINUS_TOKEN="your-psk-token"
Token Resolution
The SDK resolves the authentication token in this order:
DOMINUS_TOKENenvironment variable- Hardcoded fallback in
dominus/start.py
Architecture
┌─────────────────┐
│ Your App │
│ (async Python) │
└────────┬────────┘
│ await dominus.db.query(...)
▼
┌─────────────────┐
│ Dominus SDK │ ← JWT caching, circuit breaker, retries
│ (this package) │
└────────┬────────┘
│ HTTPS (base64-encoded JSON)
▼
┌─────────────────────────────────┐
│ Dominus Orchestrator │
│ (Cloud Run FastAPI backend) │
│ │
│ ┌─────────┬─────────┬────────┐ │
│ │ Warden │Guardian │Archivist│ │
│ │ Scribe │ Smith │Whisperer│ │
│ │ Herald │ Portal │ Courier│ │
│ └─────────┴─────────┴────────┘ │
└─────────────────────────────────┘
Dependencies
httpx- Async HTTP clientbcrypt- Password hashingcryptography- Cache encryption
Documentation
Version
v2.0.0 - Namespace-based API with unified orchestrator backend
License
Proprietary - CareBridge Systems
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dominus_sdk_python-2.1.3.tar.gz.
File metadata
- Download URL: dominus_sdk_python-2.1.3.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a08ed09dbdab8dc152b7398754a634714068b6518a3220986f9dd58509770880
|
|
| MD5 |
ca51b48ea6480639c8153b91c036199c
|
|
| BLAKE2b-256 |
6c99e5faf78edb819f54ef43f88ecc9041117ed56cb475c0bfe8e985cd659b79
|
File details
Details for the file dominus_sdk_python-2.1.3-py3-none-any.whl.
File metadata
- Download URL: dominus_sdk_python-2.1.3-py3-none-any.whl
- Upload date:
- Size: 58.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59c6a71ce11de54dcedd3b682c4c4e7b0f5f50f25431ce0d5163c1821a56c3c1
|
|
| MD5 |
f062a431ba39f8341651ddf111d8b43a
|
|
| BLAKE2b-256 |
efb8aa3644242d2153b00640f147a46e4aed9ab971cbf18651cadb3cd2b50e97
|