A client library for accessing Open Spanner API
Project description
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)
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 open_spanner-0.1.9.tar.gz.
File metadata
- Download URL: open_spanner-0.1.9.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa3f3cd7fac792f78b8b22fd11d5fe2c4abf30338c78d0c9b7fe7694181c442b
|
|
| MD5 |
4eae79e352a2078b447640f96f34f42b
|
|
| BLAKE2b-256 |
f9ca972c4fd873786fc96c66888353f8c34b659b8936323939be59f3057aad76
|
Provenance
The following attestation bundles were made for open_spanner-0.1.9.tar.gz:
Publisher:
publish-python-sdk.yml on ssubedir/open-spanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_spanner-0.1.9.tar.gz -
Subject digest:
fa3f3cd7fac792f78b8b22fd11d5fe2c4abf30338c78d0c9b7fe7694181c442b - Sigstore transparency entry: 1872609257
- Sigstore integration time:
-
Permalink:
ssubedir/open-spanner@a14f793e85b66c013fa80b83eb55190641aed2da -
Branch / Tag:
refs/tags/sdk-python-v0.1.9 - Owner: https://github.com/ssubedir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@a14f793e85b66c013fa80b83eb55190641aed2da -
Trigger Event:
push
-
Statement type:
File details
Details for the file open_spanner-0.1.9-py3-none-any.whl.
File metadata
- Download URL: open_spanner-0.1.9-py3-none-any.whl
- Upload date:
- Size: 53.4 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 |
51485830d02ada52b4fe879759c83a9efbf43f0352728883672d45ba0b3f4226
|
|
| MD5 |
621fd5141bd00fac93c50f33d71082d6
|
|
| BLAKE2b-256 |
10e686e76b286b54e693f20a7f05ed9e915b2a52134f920b2d9ac70a0620ec9b
|
Provenance
The following attestation bundles were made for open_spanner-0.1.9-py3-none-any.whl:
Publisher:
publish-python-sdk.yml on ssubedir/open-spanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_spanner-0.1.9-py3-none-any.whl -
Subject digest:
51485830d02ada52b4fe879759c83a9efbf43f0352728883672d45ba0b3f4226 - Sigstore transparency entry: 1872609341
- Sigstore integration time:
-
Permalink:
ssubedir/open-spanner@a14f793e85b66c013fa80b83eb55190641aed2da -
Branch / Tag:
refs/tags/sdk-python-v0.1.9 - Owner: https://github.com/ssubedir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@a14f793e85b66c013fa80b83eb55190641aed2da -
Trigger Event:
push
-
Statement type: