lark-billing 0.0.6__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 lark-billing might be problematic. Click here for more details.
- lark_billing-0.0.6/PKG-INFO +188 -0
- lark_billing-0.0.6/README.md +161 -0
- lark_billing-0.0.6/pyproject.toml +84 -0
- lark_billing-0.0.6/src/lark/__init__.py +522 -0
- lark_billing-0.0.6/src/lark/checkout/__init__.py +4 -0
- lark_billing-0.0.6/src/lark/checkout/client.py +214 -0
- lark_billing-0.0.6/src/lark/checkout/raw_client.py +252 -0
- lark_billing-0.0.6/src/lark/client.py +240 -0
- lark_billing-0.0.6/src/lark/core/__init__.py +105 -0
- lark_billing-0.0.6/src/lark/core/api_error.py +23 -0
- lark_billing-0.0.6/src/lark/core/client_wrapper.py +79 -0
- lark_billing-0.0.6/src/lark/core/datetime_utils.py +28 -0
- lark_billing-0.0.6/src/lark/core/file.py +67 -0
- lark_billing-0.0.6/src/lark/core/force_multipart.py +18 -0
- lark_billing-0.0.6/src/lark/core/http_client.py +543 -0
- lark_billing-0.0.6/src/lark/core/http_response.py +55 -0
- lark_billing-0.0.6/src/lark/core/jsonable_encoder.py +100 -0
- lark_billing-0.0.6/src/lark/core/pydantic_utilities.py +258 -0
- lark_billing-0.0.6/src/lark/core/query_encoder.py +58 -0
- lark_billing-0.0.6/src/lark/core/remove_none_from_dict.py +11 -0
- lark_billing-0.0.6/src/lark/core/request_options.py +35 -0
- lark_billing-0.0.6/src/lark/core/serialization.py +276 -0
- lark_billing-0.0.6/src/lark/errors/__init__.py +34 -0
- lark_billing-0.0.6/src/lark/errors/unprocessable_entity_error.py +11 -0
- lark_billing-0.0.6/src/lark/feature_access/__init__.py +4 -0
- lark_billing-0.0.6/src/lark/feature_access/client.py +102 -0
- lark_billing-0.0.6/src/lark/feature_access/raw_client.py +113 -0
- lark_billing-0.0.6/src/lark/py.typed +0 -0
- lark_billing-0.0.6/src/lark/rate_cards/__init__.py +61 -0
- lark_billing-0.0.6/src/lark/rate_cards/client.py +817 -0
- lark_billing-0.0.6/src/lark/rate_cards/raw_client.py +728 -0
- lark_billing-0.0.6/src/lark/rate_cards/types/__init__.py +63 -0
- lark_billing-0.0.6/src/lark/rate_cards/types/create_rate_card_request_billing_interval.py +5 -0
- lark_billing-0.0.6/src/lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +56 -0
- lark_billing-0.0.6/src/lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +58 -0
- lark_billing-0.0.6/src/lark/rate_cards/types/create_rate_card_version_request_version_type.py +5 -0
- lark_billing-0.0.6/src/lark/subjects/__init__.py +4 -0
- lark_billing-0.0.6/src/lark/subjects/client.py +501 -0
- lark_billing-0.0.6/src/lark/subjects/raw_client.py +633 -0
- lark_billing-0.0.6/src/lark/subscriptions/__init__.py +4 -0
- lark_billing-0.0.6/src/lark/subscriptions/client.py +462 -0
- lark_billing-0.0.6/src/lark/subscriptions/raw_client.py +495 -0
- lark_billing-0.0.6/src/lark/types/__init__.py +493 -0
- lark_billing-0.0.6/src/lark/types/aggregation.py +80 -0
- lark_billing-0.0.6/src/lark/types/amount.py +20 -0
- lark_billing-0.0.6/src/lark/types/check_feature_access_request.py +24 -0
- lark_billing-0.0.6/src/lark/types/check_feature_access_response.py +21 -0
- lark_billing-0.0.6/src/lark/types/complete_subscription_checkout_response.py +21 -0
- lark_billing-0.0.6/src/lark/types/count_aggregation_pricing_metric_interface.py +17 -0
- lark_billing-0.0.6/src/lark/types/create_credit_grant_interface.py +27 -0
- lark_billing-0.0.6/src/lark/types/create_credit_grant_interface_expiration.py +27 -0
- lark_billing-0.0.6/src/lark/types/create_credit_pool_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/create_dimension_coordinate_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/create_dimension_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/create_dimensional_usage_based_rate_interface.py +32 -0
- lark_billing-0.0.6/src/lark/types/create_fixed_rate_interface.py +28 -0
- lark_billing-0.0.6/src/lark/types/create_pricing_matrix_cell_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/create_pricing_matrix_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/create_pricing_metric_interface.py +26 -0
- lark_billing-0.0.6/src/lark/types/create_pricing_plan_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_response.py +36 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_response_billing_interval.py +5 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_response_usage_based_rates_item.py +58 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_version_response.py +36 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_version_response_billing_interval.py +5 -0
- lark_billing-0.0.6/src/lark/types/create_rate_card_version_response_usage_based_rates_item.py +59 -0
- lark_billing-0.0.6/src/lark/types/create_simple_usage_based_rate_interface.py +30 -0
- lark_billing-0.0.6/src/lark/types/create_subject_response.py +24 -0
- lark_billing-0.0.6/src/lark/types/create_subscription_checkout_session_response.py +23 -0
- lark_billing-0.0.6/src/lark/types/create_usage_event_summary_response.py +23 -0
- lark_billing-0.0.6/src/lark/types/credit_grant.py +5 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_date_time_expiration_interface.py +19 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_date_time_expiration_resource.py +19 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_duration_expiration_interface.py +21 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_duration_expiration_resource.py +21 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_interface.py +28 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_interface_input_expiration.py +27 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_interface_output_expiration.py +43 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_interface_output_schedule.py +41 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_resource.py +28 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_resource_input_expiration.py +27 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_resource_input_schedule.py +39 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_resource_output_expiration.py +43 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_resource_output_schedule.py +39 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_schedule.py +5 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_schedule_one_time_interface.py +19 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_schedule_one_time_resource.py +17 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_schedule_rate_cycle_start_interface.py +19 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_schedule_rate_cycle_start_resource.py +17 -0
- lark_billing-0.0.6/src/lark/types/credit_grant_subject_granting_config_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/credit_pool.py +5 -0
- lark_billing-0.0.6/src/lark/types/credit_pool_rollover_config.py +5 -0
- lark_billing-0.0.6/src/lark/types/custom_aggregation_pricing_metric_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/custom_pricing_metric.py +5 -0
- lark_billing-0.0.6/src/lark/types/custom_unit.py +5 -0
- lark_billing-0.0.6/src/lark/types/custom_unit_amount.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimension.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimension_coordinate.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimension_coordinate_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/dimension_coordinate_set.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimension_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/dimensional_rate_matrix.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimensional_rate_matrix_cell.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimensional_usage_based_rate.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimensional_usage_based_rate_input.py +5 -0
- lark_billing-0.0.6/src/lark/types/dimensional_usage_based_rate_interface.py +33 -0
- lark_billing-0.0.6/src/lark/types/feature_access_resource.py +21 -0
- lark_billing-0.0.6/src/lark/types/fixed_rate_interface.py +29 -0
- lark_billing-0.0.6/src/lark/types/flat_price.py +24 -0
- lark_billing-0.0.6/src/lark/types/get_rate_card_response.py +36 -0
- lark_billing-0.0.6/src/lark/types/get_rate_card_response_billing_interval.py +5 -0
- lark_billing-0.0.6/src/lark/types/get_rate_card_response_usage_based_rates_item.py +58 -0
- lark_billing-0.0.6/src/lark/types/grant_credits_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/http_validation_error.py +20 -0
- lark_billing-0.0.6/src/lark/types/last_aggregation_pricing_metric_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/license_based_rate.py +5 -0
- lark_billing-0.0.6/src/lark/types/license_based_rate_input.py +5 -0
- lark_billing-0.0.6/src/lark/types/list_rate_cards_response.py +21 -0
- lark_billing-0.0.6/src/lark/types/list_subjects_response.py +21 -0
- lark_billing-0.0.6/src/lark/types/list_subscriptions_response.py +21 -0
- lark_billing-0.0.6/src/lark/types/max_aggregation_pricing_metric_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/monetary_amount.py +5 -0
- lark_billing-0.0.6/src/lark/types/package_price.py +27 -0
- lark_billing-0.0.6/src/lark/types/package_price_rounding_behavior.py +5 -0
- lark_billing-0.0.6/src/lark/types/package_price_wrapper.py +5 -0
- lark_billing-0.0.6/src/lark/types/period.py +22 -0
- lark_billing-0.0.6/src/lark/types/price.py +5 -0
- lark_billing-0.0.6/src/lark/types/pricing_matrix_cell_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/pricing_matrix_interface.py +20 -0
- lark_billing-0.0.6/src/lark/types/pricing_metric.py +5 -0
- lark_billing-0.0.6/src/lark/types/pricing_metric_interface.py +27 -0
- lark_billing-0.0.6/src/lark/types/pricing_plan.py +5 -0
- lark_billing-0.0.6/src/lark/types/pricing_plan_subscription.py +5 -0
- lark_billing-0.0.6/src/lark/types/pricing_tier.py +5 -0
- lark_billing-0.0.6/src/lark/types/rate_card.py +5 -0
- lark_billing-0.0.6/src/lark/types/rate_card_resource.py +36 -0
- lark_billing-0.0.6/src/lark/types/rate_card_resource_billing_interval.py +5 -0
- lark_billing-0.0.6/src/lark/types/rate_card_resource_usage_based_rates_item.py +58 -0
- lark_billing-0.0.6/src/lark/types/rate_card_version.py +5 -0
- lark_billing-0.0.6/src/lark/types/rate_card_version_input.py +5 -0
- lark_billing-0.0.6/src/lark/types/simple_usage_based_rate.py +5 -0
- lark_billing-0.0.6/src/lark/types/simple_usage_based_rate_input.py +5 -0
- lark_billing-0.0.6/src/lark/types/simple_usage_based_rate_interface.py +31 -0
- lark_billing-0.0.6/src/lark/types/status.py +5 -0
- lark_billing-0.0.6/src/lark/types/subject.py +5 -0
- lark_billing-0.0.6/src/lark/types/subject_granting_config.py +5 -0
- lark_billing-0.0.6/src/lark/types/subject_granting_config_resource.py +20 -0
- lark_billing-0.0.6/src/lark/types/subject_resource.py +24 -0
- lark_billing-0.0.6/src/lark/types/subscription_resource.py +28 -0
- lark_billing-0.0.6/src/lark/types/sum_aggregation_pricing_metric_interface.py +22 -0
- lark_billing-0.0.6/src/lark/types/tiered_price.py +5 -0
- lark_billing-0.0.6/src/lark/types/tiered_price_wrapper.py +5 -0
- lark_billing-0.0.6/src/lark/types/unit.py +5 -0
- lark_billing-0.0.6/src/lark/types/update_pricing_plan_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/update_rate_card_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/update_subscription_request.py +5 -0
- lark_billing-0.0.6/src/lark/types/usage_based_rate.py +5 -0
- lark_billing-0.0.6/src/lark/types/usage_based_rate_input.py +5 -0
- lark_billing-0.0.6/src/lark/types/usage_unit.py +5 -0
- lark_billing-0.0.6/src/lark/types/validation_error.py +22 -0
- lark_billing-0.0.6/src/lark/types/validation_error_loc_item.py +5 -0
- lark_billing-0.0.6/src/lark/usage_events/__init__.py +34 -0
- lark_billing-0.0.6/src/lark/usage_events/client.py +293 -0
- lark_billing-0.0.6/src/lark/usage_events/raw_client.py +318 -0
- lark_billing-0.0.6/src/lark/usage_events/types/__init__.py +36 -0
- lark_billing-0.0.6/src/lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +5 -0
- lark_billing-0.0.6/src/lark/version.py +3 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: lark-billing
|
|
3
|
+
Version: 0.0.6
|
|
4
|
+
Summary:
|
|
5
|
+
Requires-Python: >=3.8,<4.0
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Dist: httpx (>=0.21.2)
|
|
22
|
+
Requires-Dist: pydantic (>=1.9.2)
|
|
23
|
+
Requires-Dist: pydantic-core (>=2.18.2)
|
|
24
|
+
Requires-Dist: typing_extensions (>=4.0.0)
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Lark Python Library
|
|
28
|
+
|
|
29
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ffern-demo%2Flark-python-sdk)
|
|
30
|
+
[](https://pypi.python.org/pypi/lark-billing)
|
|
31
|
+
|
|
32
|
+
The Lark Python library provides convenient access to the Lark APIs from Python.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pip install lark-billing
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Reference
|
|
41
|
+
|
|
42
|
+
A full reference for this library is available [here](https://github.com/fern-demo/lark-python-sdk/blob/HEAD/./reference.md).
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
Instantiate and use the client with the following:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from lark import Lark
|
|
50
|
+
|
|
51
|
+
client = Lark(
|
|
52
|
+
api_key="YOUR_API_KEY",
|
|
53
|
+
base_url="https://yourhost.com/path/to/api",
|
|
54
|
+
)
|
|
55
|
+
client.checkout.create_subscription_checkout_session(
|
|
56
|
+
subject_id="subject_id",
|
|
57
|
+
rate_card_id="rate_card_id",
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Async Client
|
|
62
|
+
|
|
63
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
|
|
68
|
+
from lark import AsyncLark
|
|
69
|
+
|
|
70
|
+
client = AsyncLark(
|
|
71
|
+
api_key="YOUR_API_KEY",
|
|
72
|
+
base_url="https://yourhost.com/path/to/api",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
await client.checkout.create_subscription_checkout_session(
|
|
78
|
+
subject_id="subject_id",
|
|
79
|
+
rate_card_id="rate_card_id",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
asyncio.run(main())
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Exception Handling
|
|
87
|
+
|
|
88
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
89
|
+
will be thrown.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from lark.core.api_error import ApiError
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
client.checkout.create_subscription_checkout_session(...)
|
|
96
|
+
except ApiError as e:
|
|
97
|
+
print(e.status_code)
|
|
98
|
+
print(e.body)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Advanced
|
|
102
|
+
|
|
103
|
+
### Access Raw Response Data
|
|
104
|
+
|
|
105
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
106
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from lark import Lark
|
|
110
|
+
|
|
111
|
+
client = Lark(
|
|
112
|
+
...,
|
|
113
|
+
)
|
|
114
|
+
response = (
|
|
115
|
+
client.checkout.with_raw_response.create_subscription_checkout_session(...)
|
|
116
|
+
)
|
|
117
|
+
print(response.headers) # access the response headers
|
|
118
|
+
print(response.data) # access the underlying object
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Retries
|
|
122
|
+
|
|
123
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
124
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
125
|
+
retry limit (default: 2).
|
|
126
|
+
|
|
127
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
128
|
+
|
|
129
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
130
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
131
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
132
|
+
|
|
133
|
+
Use the `max_retries` request option to configure this behavior.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
client.checkout.create_subscription_checkout_session(..., request_options={
|
|
137
|
+
"max_retries": 1
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Timeouts
|
|
142
|
+
|
|
143
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
|
|
147
|
+
from lark import Lark
|
|
148
|
+
|
|
149
|
+
client = Lark(
|
|
150
|
+
...,
|
|
151
|
+
timeout=20.0,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# Override timeout for a specific method
|
|
156
|
+
client.checkout.create_subscription_checkout_session(..., request_options={
|
|
157
|
+
"timeout_in_seconds": 1
|
|
158
|
+
})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Custom Client
|
|
162
|
+
|
|
163
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
164
|
+
and transports.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
import httpx
|
|
168
|
+
from lark import Lark
|
|
169
|
+
|
|
170
|
+
client = Lark(
|
|
171
|
+
...,
|
|
172
|
+
httpx_client=httpx.Client(
|
|
173
|
+
proxy="http://my.test.proxy.example.com",
|
|
174
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
175
|
+
),
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Contributing
|
|
180
|
+
|
|
181
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
182
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
183
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
184
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
185
|
+
an issue first to discuss with us!
|
|
186
|
+
|
|
187
|
+
On the other hand, contributions to the README are always very welcome!
|
|
188
|
+
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Lark Python Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ffern-demo%2Flark-python-sdk)
|
|
4
|
+
[](https://pypi.python.org/pypi/lark-billing)
|
|
5
|
+
|
|
6
|
+
The Lark Python library provides convenient access to the Lark APIs from Python.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pip install lark-billing
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Reference
|
|
15
|
+
|
|
16
|
+
A full reference for this library is available [here](https://github.com/fern-demo/lark-python-sdk/blob/HEAD/./reference.md).
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Instantiate and use the client with the following:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from lark import Lark
|
|
24
|
+
|
|
25
|
+
client = Lark(
|
|
26
|
+
api_key="YOUR_API_KEY",
|
|
27
|
+
base_url="https://yourhost.com/path/to/api",
|
|
28
|
+
)
|
|
29
|
+
client.checkout.create_subscription_checkout_session(
|
|
30
|
+
subject_id="subject_id",
|
|
31
|
+
rate_card_id="rate_card_id",
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Async Client
|
|
36
|
+
|
|
37
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import asyncio
|
|
41
|
+
|
|
42
|
+
from lark import AsyncLark
|
|
43
|
+
|
|
44
|
+
client = AsyncLark(
|
|
45
|
+
api_key="YOUR_API_KEY",
|
|
46
|
+
base_url="https://yourhost.com/path/to/api",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def main() -> None:
|
|
51
|
+
await client.checkout.create_subscription_checkout_session(
|
|
52
|
+
subject_id="subject_id",
|
|
53
|
+
rate_card_id="rate_card_id",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
asyncio.run(main())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Exception Handling
|
|
61
|
+
|
|
62
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
63
|
+
will be thrown.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from lark.core.api_error import ApiError
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
client.checkout.create_subscription_checkout_session(...)
|
|
70
|
+
except ApiError as e:
|
|
71
|
+
print(e.status_code)
|
|
72
|
+
print(e.body)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Advanced
|
|
76
|
+
|
|
77
|
+
### Access Raw Response Data
|
|
78
|
+
|
|
79
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
80
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from lark import Lark
|
|
84
|
+
|
|
85
|
+
client = Lark(
|
|
86
|
+
...,
|
|
87
|
+
)
|
|
88
|
+
response = (
|
|
89
|
+
client.checkout.with_raw_response.create_subscription_checkout_session(...)
|
|
90
|
+
)
|
|
91
|
+
print(response.headers) # access the response headers
|
|
92
|
+
print(response.data) # access the underlying object
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Retries
|
|
96
|
+
|
|
97
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
98
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
99
|
+
retry limit (default: 2).
|
|
100
|
+
|
|
101
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
102
|
+
|
|
103
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
104
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
105
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
106
|
+
|
|
107
|
+
Use the `max_retries` request option to configure this behavior.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
client.checkout.create_subscription_checkout_session(..., request_options={
|
|
111
|
+
"max_retries": 1
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Timeouts
|
|
116
|
+
|
|
117
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
|
|
121
|
+
from lark import Lark
|
|
122
|
+
|
|
123
|
+
client = Lark(
|
|
124
|
+
...,
|
|
125
|
+
timeout=20.0,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# Override timeout for a specific method
|
|
130
|
+
client.checkout.create_subscription_checkout_session(..., request_options={
|
|
131
|
+
"timeout_in_seconds": 1
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Custom Client
|
|
136
|
+
|
|
137
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
138
|
+
and transports.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import httpx
|
|
142
|
+
from lark import Lark
|
|
143
|
+
|
|
144
|
+
client = Lark(
|
|
145
|
+
...,
|
|
146
|
+
httpx_client=httpx.Client(
|
|
147
|
+
proxy="http://my.test.proxy.example.com",
|
|
148
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
156
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
157
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
158
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
159
|
+
an issue first to discuss with us!
|
|
160
|
+
|
|
161
|
+
On the other hand, contributions to the README are always very welcome!
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "lark-billing"
|
|
3
|
+
|
|
4
|
+
[tool.poetry]
|
|
5
|
+
name = "lark-billing"
|
|
6
|
+
version = "0.0.6"
|
|
7
|
+
description = ""
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
authors = []
|
|
10
|
+
keywords = []
|
|
11
|
+
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Programming Language :: Python",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.8",
|
|
17
|
+
"Programming Language :: Python :: 3.9",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Operating System :: POSIX",
|
|
23
|
+
"Operating System :: MacOS",
|
|
24
|
+
"Operating System :: POSIX :: Linux",
|
|
25
|
+
"Operating System :: Microsoft :: Windows",
|
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
+
"Typing :: Typed"
|
|
28
|
+
]
|
|
29
|
+
packages = [
|
|
30
|
+
{ include = "lark", from = "src"}
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Repository = 'https://github.com/fern-demo/lark-python-sdk'
|
|
35
|
+
|
|
36
|
+
[tool.poetry.dependencies]
|
|
37
|
+
python = "^3.8"
|
|
38
|
+
httpx = ">=0.21.2"
|
|
39
|
+
pydantic = ">= 1.9.2"
|
|
40
|
+
pydantic-core = ">=2.18.2"
|
|
41
|
+
typing_extensions = ">= 4.0.0"
|
|
42
|
+
|
|
43
|
+
[tool.poetry.group.dev.dependencies]
|
|
44
|
+
mypy = "==1.13.0"
|
|
45
|
+
pytest = "^7.4.0"
|
|
46
|
+
pytest-asyncio = "^0.23.5"
|
|
47
|
+
python-dateutil = "^2.9.0"
|
|
48
|
+
types-python-dateutil = "^2.9.0.20240316"
|
|
49
|
+
ruff = "==0.11.5"
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
testpaths = [ "tests" ]
|
|
53
|
+
asyncio_mode = "auto"
|
|
54
|
+
|
|
55
|
+
[tool.mypy]
|
|
56
|
+
plugins = ["pydantic.mypy"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 120
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = [
|
|
63
|
+
"E", # pycodestyle errors
|
|
64
|
+
"F", # pyflakes
|
|
65
|
+
"I", # isort
|
|
66
|
+
]
|
|
67
|
+
ignore = [
|
|
68
|
+
"E402", # Module level import not at top of file
|
|
69
|
+
"E501", # Line too long
|
|
70
|
+
"E711", # Comparison to `None` should be `cond is not None`
|
|
71
|
+
"E712", # Avoid equality comparisons to `True`; use `if ...:` checks
|
|
72
|
+
"E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
|
|
73
|
+
"E722", # Do not use bare `except`
|
|
74
|
+
"E731", # Do not assign a `lambda` expression, use a `def`
|
|
75
|
+
"F821", # Undefined name
|
|
76
|
+
"F841" # Local variable ... is assigned to but never used
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint.isort]
|
|
80
|
+
section-order = ["future", "standard-library", "third-party", "first-party"]
|
|
81
|
+
|
|
82
|
+
[build-system]
|
|
83
|
+
requires = ["poetry-core"]
|
|
84
|
+
build-backend = "poetry.core.masonry.api"
|