A litewave library to collect the customer credit usage
Project description
meter-lib — Usage Guide
Overview
meter-lib is a lightweight helper library for sending metering events to the Litewave backend and for looking up a customer account by tenant_id.
Requirements
- Python 3.10+
Installation
pip install meter-lib
Parameters Required
tenant_id,
device_id,
meter_id,
total_usage
Quickstart
from meter_lib import post_meter_usage
tenant_id = "tenant_123"
device_id = "device_456"
meter_id = "pages.processed.rate.hourly"
result = post_meter_usage(
tenant_id=tenant_id,
device_id=device_id,
meter_id=meter_id,
total_usage=24, # integer units as defined by your meter
)
if result is None:
# Handle network error or non-2xx response
print("Failed to post meter usage event")
else:
print("Event accepted:", result)
Error Handling
post_meter_usagereturnsNonefor network errors or non-success HTTP statuses.- Prefer explicit checks for
Noneand add retries or backoff in your application layer if needed.
API Reference
post_meter_usage(tenant_id: str, device_id: str, meter_id: str, total_usage: int) -> dict | None
- Description: Posts a metering event for a device and meter under a given tenant.
- Headers:
x-tenant-id: the tenant identifier (string)x-device-id: the device identifier (string)
- Payload (JSON):
meter_id(string)total_usage(integer)customer_id(string) — auto-filled by the library.`
- Returns: The backend JSON response (
dict) on success, otherwiseNone. - Timeout: 10 seconds.
- Notes:
- If the customer lookup fails, the call is skipped and
Noneis returned. - This function is synchronous and will block until the request completes or times out.
- If the customer lookup fails, the call is skipped and
Troubleshooting
- Confirm your
tenant_id,device_id, andmeter_idvalues are correct.
Support
- Homepage:
https://github.com/aiorch/meter-lib - Issues:
https://github.com/aiorch/meter-lib/issues
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
meter_lib-0.0.3.tar.gz
(4.5 kB
view details)
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 meter_lib-0.0.3.tar.gz.
File metadata
- Download URL: meter_lib-0.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31d7d461fcbdcff681c06f42ea3cbf6730cfee3e71a34736b6bfa7a3eae9ad41
|
|
| MD5 |
915b6303bb346315e7d1b6061973f790
|
|
| BLAKE2b-256 |
a9ee8dc5b8faad26f6fe1dcf18d129ae3caef19c52fe0ec212577196f43beafa
|
File details
Details for the file meter_lib-0.0.3-py3-none-any.whl.
File metadata
- Download URL: meter_lib-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
775f43e3f32a26e41aa0e49ea986eb056ea3a0f52ae6b948dfa65231c3d67ad8
|
|
| MD5 |
63eb24e2d1608e1a88b8a8dbc2f5a7c4
|
|
| BLAKE2b-256 |
e9750ad5a648dc9620dcabca07a10c7aa52c8abc6a9523c9914b5fdf5f9de69b
|