Python client for the SGRS governance platform — HTTP + optional NATS real-time events
Project description
sgrs-client
Python HTTP client for the SGRS REST API.
Installation
pip install sgrs-client
Quick Start
Async Usage
import asyncio
from sgrs_client import create_client
async def main():
client = create_client(base_url='http://localhost:3000')
# Get a scope
response = await client.get_scope('my-scope')
if response.ok:
print(f"Scope: {response.data}")
else:
print(f"Error: {response.error}")
await client.close()
asyncio.run(main())
Sync Usage
from sgrs_client import create_client
client = create_client(base_url='http://localhost:3000')
# Get a scope
response = client.get_scope_sync('my-scope')
if response.ok:
print(f"Scope: {response.data}")
else:
print(f"Error: {response.error}")
client._sync_client.close()
Context Manager
import asyncio
from sgrs_client import create_client
async def main():
async with create_client(base_url='http://localhost:3000') as client:
response = await client.get_scope('my-scope')
print(response.data if response.ok else response.error)
asyncio.run(main())
Features
- Type-safe: All types validated with Pydantic models
- Async-first: Full async/await support with fallback to sync
- Schema validation: Runtime validation using models derived from Zod schemas
- Error handling: Structured error responses with detailed information
- Timeouts: Configurable request timeouts
- SSL verification: Configurable SSL certificate verification
Scopes API
# Get a scope
response = await client.get_scope('scope-id')
# Create a scope
response = await client.create_scope(
name='My Scope',
tag='tag',
state='active',
score=0.5,
cycles=0
)
# Update a scope
response = await client.update_scope('scope-id', score=0.75)
Models API
from sgrs_client import ConnectModelRequest
# Connect a model provider
request = ConnectModelRequest(
provider='openai',
api_key='sk-...',
model='gpt-4'
)
response = await client.connect_model(request)
# Get a connected model
response = await client.get_model('mh_xxx')
Finality API
# Get finality status
response = await client.get_finality_status('scope-id')
# Get finality certificate
response = await client.get_finality_certificate('scope-id', round=1)
Documentation (Sphinx)
From the repository root, pnpm docs:py runs scripts/docs-py.sh, which maintains packages/client-py/.venv so installs work on PEP-668–managed Pythons:
pnpm docs:py
Generated HTML: packages/client-py/docs/_build/html/ (Sphinx sources in packages/client-py/docs/).
License
MIT - see LICENSE file
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 sgrs_client-0.0.0.tar.gz.
File metadata
- Download URL: sgrs_client-0.0.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e40cd5e9b68dd23b67cce5132b1d26e5e36da3f014fd7af4a30436a8fb56aa4
|
|
| MD5 |
8278d24329a82b457c117f0ed2431394
|
|
| BLAKE2b-256 |
2a2e4f2a06f679dca71756d41f215862c6804b85b0c934f2a5c74cab66f4448f
|
Provenance
The following attestation bundles were made for sgrs_client-0.0.0.tar.gz:
Publisher:
release-py.yml on DealExMachina/sgrs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sgrs_client-0.0.0.tar.gz -
Subject digest:
6e40cd5e9b68dd23b67cce5132b1d26e5e36da3f014fd7af4a30436a8fb56aa4 - Sigstore transparency entry: 1418387669
- Sigstore integration time:
-
Permalink:
DealExMachina/sgrs@a9dfa515bb95c75990c197b47a87bed19bfbde71 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DealExMachina
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-py.yml@a9dfa515bb95c75990c197b47a87bed19bfbde71 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sgrs_client-0.0.0-py3-none-any.whl.
File metadata
- Download URL: sgrs_client-0.0.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8d97bc964ff6c15098c7c41b31a10a5edf7de6d44d1fdf2d9a6a96447405efb
|
|
| MD5 |
306aa1979b80e300e059a937761fb31a
|
|
| BLAKE2b-256 |
2a5beb4f96864495490cee9672548756a1a7225b8189fd9f92e99f52b28001bb
|
Provenance
The following attestation bundles were made for sgrs_client-0.0.0-py3-none-any.whl:
Publisher:
release-py.yml on DealExMachina/sgrs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sgrs_client-0.0.0-py3-none-any.whl -
Subject digest:
b8d97bc964ff6c15098c7c41b31a10a5edf7de6d44d1fdf2d9a6a96447405efb - Sigstore transparency entry: 1418387757
- Sigstore integration time:
-
Permalink:
DealExMachina/sgrs@a9dfa515bb95c75990c197b47a87bed19bfbde71 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DealExMachina
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-py.yml@a9dfa515bb95c75990c197b47a87bed19bfbde71 -
Trigger Event:
workflow_dispatch
-
Statement type: