Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sgrs_client-0.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sgrs_client-0.0.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

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

Hashes for sgrs_client-0.0.0.tar.gz
Algorithm Hash digest
SHA256 6e40cd5e9b68dd23b67cce5132b1d26e5e36da3f014fd7af4a30436a8fb56aa4
MD5 8278d24329a82b457c117f0ed2431394
BLAKE2b-256 2a2e4f2a06f679dca71756d41f215862c6804b85b0c934f2a5c74cab66f4448f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sgrs_client-0.0.0.tar.gz:

Publisher: release-py.yml on DealExMachina/sgrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for sgrs_client-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8d97bc964ff6c15098c7c41b31a10a5edf7de6d44d1fdf2d9a6a96447405efb
MD5 306aa1979b80e300e059a937761fb31a
BLAKE2b-256 2a5beb4f96864495490cee9672548756a1a7225b8189fd9f92e99f52b28001bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sgrs_client-0.0.0-py3-none-any.whl:

Publisher: release-py.yml on DealExMachina/sgrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page