meter-lib 0.0.2__tar.gz → 0.0.3__tar.gz

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,79 @@
1
+ ## meter-lib — Usage Guide
2
+
3
+ ### Overview
4
+
5
+ `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`.
6
+
7
+ ### Requirements
8
+
9
+ - Python 3.10+
10
+
11
+ ### Installation
12
+
13
+ ```bash
14
+ pip install meter-lib
15
+ ```
16
+
17
+ ### Parameters Required
18
+
19
+ ```
20
+ tenant_id,
21
+ device_id,
22
+ meter_id,
23
+ total_usage
24
+ ```
25
+
26
+ ### Quickstart
27
+
28
+ ```python
29
+ from meter_lib import post_meter_usage
30
+
31
+ tenant_id = "tenant_123"
32
+ device_id = "device_456"
33
+ meter_id = "pages.processed.rate.hourly"
34
+
35
+ result = post_meter_usage(
36
+ tenant_id=tenant_id,
37
+ device_id=device_id,
38
+ meter_id=meter_id,
39
+ total_usage=24, # integer units as defined by your meter
40
+ )
41
+
42
+ if result is None:
43
+ # Handle network error or non-2xx response
44
+ print("Failed to post meter usage event")
45
+ else:
46
+ print("Event accepted:", result)
47
+ ```
48
+
49
+ ### Error Handling
50
+
51
+ - `post_meter_usage` returns `None` for network errors or non-success HTTP statuses.
52
+ - Prefer explicit checks for `None` and add retries or backoff in your application layer if needed.
53
+
54
+ ### API Reference
55
+
56
+ #### post_meter_usage(tenant_id: str, device_id: str, meter_id: str, total_usage: int) -> dict | None
57
+
58
+ - **Description**: Posts a metering event for a device and meter under a given tenant.
59
+ - **Headers**:
60
+ - `x-tenant-id`: the tenant identifier (string)
61
+ - `x-device-id`: the device identifier (string)
62
+ - **Payload (JSON)**:
63
+ - `meter_id` (string)
64
+ - `total_usage` (integer)
65
+ - `customer_id` (string) — auto-filled by the library.`
66
+ - **Returns**: The backend JSON response (`dict`) on success, otherwise `None`.
67
+ - **Timeout**: 10 seconds.
68
+ - **Notes**:
69
+ - If the customer lookup fails, the call is skipped and `None` is returned.
70
+ - This function is synchronous and will block until the request completes or times out.
71
+
72
+ ### Troubleshooting
73
+
74
+ - Confirm your `tenant_id`, `device_id`, and `meter_id` values are correct.
75
+
76
+ ### Support
77
+
78
+ - Homepage: `https://github.com/aiorch/meter-lib`
79
+ - Issues: `https://github.com/aiorch/meter-lib/issues`
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meter-lib"
7
- version = "0.0.2"
7
+ version = "0.0.3"
8
8
  description = "A litewave library to collect the customer credit usage"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -10,7 +10,7 @@ with open("requirements.txt", "r", encoding="utf-8") as fh:
10
10
 
11
11
  setup(
12
12
  name="meter-lib",
13
- version="0.0.2",
13
+ version="0.0.3",
14
14
  author="Sruthi R",
15
15
  author_email="sruthi@litewave.ai",
16
16
  description="A litewave library to collect the customer credit usage",
meter_lib-0.0.2/PKG-INFO DELETED
@@ -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
meter_lib-0.0.2/README.md DELETED
@@ -1 +0,0 @@
1
- # meter-lib
File without changes
File without changes
File without changes