meter-lib 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of meter-lib might be problematic. Click here for more details.

@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: meter-lib
3
+ Version: 0.0.3
4
+ Summary: A litewave library to collect the customer credit usage
5
+ Project-URL: Homepage, https://github.com/aiorch/meter-lib
6
+ Project-URL: Repository, https://github.com/aiorch/meter-lib
7
+ Project-URL: Issues, https://github.com/aiorch/meter-lib/issues
8
+ Author-email: Sruthi <sruthi@litewave.ai>
9
+ License: MIT
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: requests>=2.28
17
+ Description-Content-Type: text/markdown
18
+
19
+ ## meter-lib — Usage Guide
20
+
21
+ ### Overview
22
+
23
+ `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`.
24
+
25
+ ### Requirements
26
+
27
+ - Python 3.10+
28
+
29
+ ### Installation
30
+
31
+ ```bash
32
+ pip install meter-lib
33
+ ```
34
+
35
+ ### Parameters Required
36
+
37
+ ```
38
+ tenant_id,
39
+ device_id,
40
+ meter_id,
41
+ total_usage
42
+ ```
43
+
44
+ ### Quickstart
45
+
46
+ ```python
47
+ from meter_lib import post_meter_usage
48
+
49
+ tenant_id = "tenant_123"
50
+ device_id = "device_456"
51
+ meter_id = "pages.processed.rate.hourly"
52
+
53
+ result = post_meter_usage(
54
+ tenant_id=tenant_id,
55
+ device_id=device_id,
56
+ meter_id=meter_id,
57
+ total_usage=24, # integer units as defined by your meter
58
+ )
59
+
60
+ if result is None:
61
+ # Handle network error or non-2xx response
62
+ print("Failed to post meter usage event")
63
+ else:
64
+ print("Event accepted:", result)
65
+ ```
66
+
67
+ ### Error Handling
68
+
69
+ - `post_meter_usage` returns `None` for network errors or non-success HTTP statuses.
70
+ - Prefer explicit checks for `None` and add retries or backoff in your application layer if needed.
71
+
72
+ ### API Reference
73
+
74
+ #### post_meter_usage(tenant_id: str, device_id: str, meter_id: str, total_usage: int) -> dict | None
75
+
76
+ - **Description**: Posts a metering event for a device and meter under a given tenant.
77
+ - **Headers**:
78
+ - `x-tenant-id`: the tenant identifier (string)
79
+ - `x-device-id`: the device identifier (string)
80
+ - **Payload (JSON)**:
81
+ - `meter_id` (string)
82
+ - `total_usage` (integer)
83
+ - `customer_id` (string) — auto-filled by the library.`
84
+ - **Returns**: The backend JSON response (`dict`) on success, otherwise `None`.
85
+ - **Timeout**: 10 seconds.
86
+ - **Notes**:
87
+ - If the customer lookup fails, the call is skipped and `None` is returned.
88
+ - This function is synchronous and will block until the request completes or times out.
89
+
90
+ ### Troubleshooting
91
+
92
+ - Confirm your `tenant_id`, `device_id`, and `meter_id` values are correct.
93
+
94
+ ### Support
95
+
96
+ - Homepage: `https://github.com/aiorch/meter-lib`
97
+ - Issues: `https://github.com/aiorch/meter-lib/issues`
@@ -0,0 +1,5 @@
1
+ meter_lib/__init__.py,sha256=3iRDH_E4qSKZVLaiJAs4YjoFC8jPIvH4sbgL6x4pAT8,53
2
+ meter_lib/core.py,sha256=Qi5OL4rg4iwweDTeBOljYrnSwU19SgU8naIA2cflGSo,1824
3
+ meter_lib-0.0.3.dist-info/METADATA,sha256=4GpY9I59GEyveMX3r7GLbzuFHBvOxDBWZk234C00M88,2716
4
+ meter_lib-0.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ meter_lib-0.0.3.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: meter-lib
3
- Version: 0.0.2
4
- Summary: A litewave library to collect the customer credit usage
5
- Project-URL: Homepage, https://github.com/aiorch/meter-lib
6
- Project-URL: Repository, https://github.com/aiorch/meter-lib
7
- Project-URL: Issues, https://github.com/aiorch/meter-lib/issues
8
- Author-email: Sruthi <sruthi@litewave.ai>
9
- License: MIT
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Requires-Python: >=3.10
16
- Requires-Dist: requests>=2.28
17
- Description-Content-Type: text/markdown
18
-
19
- # meter-lib
@@ -1,5 +0,0 @@
1
- meter_lib/__init__.py,sha256=3iRDH_E4qSKZVLaiJAs4YjoFC8jPIvH4sbgL6x4pAT8,53
2
- meter_lib/core.py,sha256=Qi5OL4rg4iwweDTeBOljYrnSwU19SgU8naIA2cflGSo,1824
3
- meter_lib-0.0.2.dist-info/METADATA,sha256=bMPeM5NU5YA3Go0moCWkXUqw4YrgU0ZNDbuU2ybMr6g,715
4
- meter_lib-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- meter_lib-0.0.2.dist-info/RECORD,,