Skip to main content

open-spanner

Python client for the Open Spanner API.

Install from PyPI:

pip install open-spanner

Record usage for a meter that already exists:

from datetime import UTC, datetime
from uuid import uuid4

from open_spanner_client import AuthenticatedClient
from open_spanner_client.api.usages import create_usage
from open_spanner_client.models.usage_create_request import UsageCreateRequest

api_key = "..."

client = AuthenticatedClient(
    base_url="https://api.example.com",
    token=api_key,
    raise_on_unexpected_status=True,
)

usage = create_usage.sync(
    client=client,
    body=UsageCreateRequest(
        idempotency_key=str(uuid4()),
        subject="org_123",
        meter="api_requests",
        quantity=1,
        timestamp=datetime.now(UTC).isoformat(),
    ),
)

print(usage.id)

Stream usage over gRPC:

from datetime import UTC, datetime

from open_spanner_client.stream import Event, StreamClient

client = StreamClient("localhost:18090", "osp_...")
try:
    result = client.track_bulk(
        "batch-1",
        [
            Event(
                idempotency_key="usage-1",
                subject="org_123",
                meter="api_requests",
                quantity=1,
                timestamp=datetime.now(UTC),
                metadata={"endpoint": "/v1/orders", "status": 200},
            )
        ],
    )
finally:
    client.close()

print(result.accepted_count)

Download files

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

Source Distribution

open_spanner-0.1.12.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

open_spanner-0.1.12-py3-none-any.whl (67.0 kB view details)

Uploaded Python 3

File details

Details for the file open_spanner-0.1.12.tar.gz.

File metadata

  • Download URL: open_spanner-0.1.12.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for open_spanner-0.1.12.tar.gz
Algorithm Hash digest
SHA256 88cba70534ffa8537caaf9ad0931869648c7836279848de47fdc629baae2dd15
MD5 cb5e818a895e506713e4827ceca208ce
BLAKE2b-256 ffc6b07d54bfdb9d3bac6ebd25d8f5692503fb85eb733862a68697c2d74f20c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_spanner-0.1.12.tar.gz:

Publisher: publish-python-sdk.yml on ssubedir/open-spanner

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

File details

Details for the file open_spanner-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: open_spanner-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 67.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for open_spanner-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0dcb38bab6a88844b7ffb549cf86b754bbdc8322e02ad0a0e2f81928a281694a
MD5 0da4caf1cb462a1230fe34b6221c9e4b
BLAKE2b-256 18d6993cd01e86a62dafdd9170ce156f07656c05b4d0df28e0c75d3ca8d2c646

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_spanner-0.1.12-py3-none-any.whl:

Publisher: publish-python-sdk.yml on ssubedir/open-spanner

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

Release history Release notifications | RSS feed

0.1.13

2 files

This release

0.1.12 This release

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page