lark-billing 0.0.6__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 lark-billing might be problematic. Click here for more details.
- lark/__init__.py +522 -0
- lark/checkout/__init__.py +4 -0
- lark/checkout/client.py +214 -0
- lark/checkout/raw_client.py +252 -0
- lark/client.py +240 -0
- lark/core/__init__.py +105 -0
- lark/core/api_error.py +23 -0
- lark/core/client_wrapper.py +79 -0
- lark/core/datetime_utils.py +28 -0
- lark/core/file.py +67 -0
- lark/core/force_multipart.py +18 -0
- lark/core/http_client.py +543 -0
- lark/core/http_response.py +55 -0
- lark/core/jsonable_encoder.py +100 -0
- lark/core/pydantic_utilities.py +258 -0
- lark/core/query_encoder.py +58 -0
- lark/core/remove_none_from_dict.py +11 -0
- lark/core/request_options.py +35 -0
- lark/core/serialization.py +276 -0
- lark/errors/__init__.py +34 -0
- lark/errors/unprocessable_entity_error.py +11 -0
- lark/feature_access/__init__.py +4 -0
- lark/feature_access/client.py +102 -0
- lark/feature_access/raw_client.py +113 -0
- lark/py.typed +0 -0
- lark/rate_cards/__init__.py +61 -0
- lark/rate_cards/client.py +817 -0
- lark/rate_cards/raw_client.py +728 -0
- lark/rate_cards/types/__init__.py +63 -0
- lark/rate_cards/types/create_rate_card_request_billing_interval.py +5 -0
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +56 -0
- lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +58 -0
- lark/rate_cards/types/create_rate_card_version_request_version_type.py +5 -0
- lark/subjects/__init__.py +4 -0
- lark/subjects/client.py +501 -0
- lark/subjects/raw_client.py +633 -0
- lark/subscriptions/__init__.py +4 -0
- lark/subscriptions/client.py +462 -0
- lark/subscriptions/raw_client.py +495 -0
- lark/types/__init__.py +493 -0
- lark/types/aggregation.py +80 -0
- lark/types/amount.py +20 -0
- lark/types/check_feature_access_request.py +24 -0
- lark/types/check_feature_access_response.py +21 -0
- lark/types/complete_subscription_checkout_response.py +21 -0
- lark/types/count_aggregation_pricing_metric_interface.py +17 -0
- lark/types/create_credit_grant_interface.py +27 -0
- lark/types/create_credit_grant_interface_expiration.py +27 -0
- lark/types/create_credit_pool_request.py +5 -0
- lark/types/create_dimension_coordinate_interface.py +20 -0
- lark/types/create_dimension_interface.py +20 -0
- lark/types/create_dimensional_usage_based_rate_interface.py +32 -0
- lark/types/create_fixed_rate_interface.py +28 -0
- lark/types/create_pricing_matrix_cell_interface.py +22 -0
- lark/types/create_pricing_matrix_interface.py +20 -0
- lark/types/create_pricing_metric_interface.py +26 -0
- lark/types/create_pricing_plan_request.py +5 -0
- lark/types/create_rate_card_response.py +36 -0
- lark/types/create_rate_card_response_billing_interval.py +5 -0
- lark/types/create_rate_card_response_usage_based_rates_item.py +58 -0
- lark/types/create_rate_card_version_response.py +36 -0
- lark/types/create_rate_card_version_response_billing_interval.py +5 -0
- lark/types/create_rate_card_version_response_usage_based_rates_item.py +59 -0
- lark/types/create_simple_usage_based_rate_interface.py +30 -0
- lark/types/create_subject_response.py +24 -0
- lark/types/create_subscription_checkout_session_response.py +23 -0
- lark/types/create_usage_event_summary_response.py +23 -0
- lark/types/credit_grant.py +5 -0
- lark/types/credit_grant_date_time_expiration_interface.py +19 -0
- lark/types/credit_grant_date_time_expiration_resource.py +19 -0
- lark/types/credit_grant_duration_expiration_interface.py +21 -0
- lark/types/credit_grant_duration_expiration_resource.py +21 -0
- lark/types/credit_grant_interface.py +28 -0
- lark/types/credit_grant_interface_input_expiration.py +27 -0
- lark/types/credit_grant_interface_output_expiration.py +43 -0
- lark/types/credit_grant_interface_output_schedule.py +41 -0
- lark/types/credit_grant_resource.py +28 -0
- lark/types/credit_grant_resource_input_expiration.py +27 -0
- lark/types/credit_grant_resource_input_schedule.py +39 -0
- lark/types/credit_grant_resource_output_expiration.py +43 -0
- lark/types/credit_grant_resource_output_schedule.py +39 -0
- lark/types/credit_grant_schedule.py +5 -0
- lark/types/credit_grant_schedule_one_time_interface.py +19 -0
- lark/types/credit_grant_schedule_one_time_resource.py +17 -0
- lark/types/credit_grant_schedule_rate_cycle_start_interface.py +19 -0
- lark/types/credit_grant_schedule_rate_cycle_start_resource.py +17 -0
- lark/types/credit_grant_subject_granting_config_interface.py +20 -0
- lark/types/credit_pool.py +5 -0
- lark/types/credit_pool_rollover_config.py +5 -0
- lark/types/custom_aggregation_pricing_metric_interface.py +22 -0
- lark/types/custom_pricing_metric.py +5 -0
- lark/types/custom_unit.py +5 -0
- lark/types/custom_unit_amount.py +5 -0
- lark/types/dimension.py +5 -0
- lark/types/dimension_coordinate.py +5 -0
- lark/types/dimension_coordinate_interface.py +20 -0
- lark/types/dimension_coordinate_set.py +5 -0
- lark/types/dimension_interface.py +20 -0
- lark/types/dimensional_rate_matrix.py +5 -0
- lark/types/dimensional_rate_matrix_cell.py +5 -0
- lark/types/dimensional_usage_based_rate.py +5 -0
- lark/types/dimensional_usage_based_rate_input.py +5 -0
- lark/types/dimensional_usage_based_rate_interface.py +33 -0
- lark/types/feature_access_resource.py +21 -0
- lark/types/fixed_rate_interface.py +29 -0
- lark/types/flat_price.py +24 -0
- lark/types/get_rate_card_response.py +36 -0
- lark/types/get_rate_card_response_billing_interval.py +5 -0
- lark/types/get_rate_card_response_usage_based_rates_item.py +58 -0
- lark/types/grant_credits_request.py +5 -0
- lark/types/http_validation_error.py +20 -0
- lark/types/last_aggregation_pricing_metric_interface.py +22 -0
- lark/types/license_based_rate.py +5 -0
- lark/types/license_based_rate_input.py +5 -0
- lark/types/list_rate_cards_response.py +21 -0
- lark/types/list_subjects_response.py +21 -0
- lark/types/list_subscriptions_response.py +21 -0
- lark/types/max_aggregation_pricing_metric_interface.py +22 -0
- lark/types/monetary_amount.py +5 -0
- lark/types/package_price.py +27 -0
- lark/types/package_price_rounding_behavior.py +5 -0
- lark/types/package_price_wrapper.py +5 -0
- lark/types/period.py +22 -0
- lark/types/price.py +5 -0
- lark/types/pricing_matrix_cell_interface.py +22 -0
- lark/types/pricing_matrix_interface.py +20 -0
- lark/types/pricing_metric.py +5 -0
- lark/types/pricing_metric_interface.py +27 -0
- lark/types/pricing_plan.py +5 -0
- lark/types/pricing_plan_subscription.py +5 -0
- lark/types/pricing_tier.py +5 -0
- lark/types/rate_card.py +5 -0
- lark/types/rate_card_resource.py +36 -0
- lark/types/rate_card_resource_billing_interval.py +5 -0
- lark/types/rate_card_resource_usage_based_rates_item.py +58 -0
- lark/types/rate_card_version.py +5 -0
- lark/types/rate_card_version_input.py +5 -0
- lark/types/simple_usage_based_rate.py +5 -0
- lark/types/simple_usage_based_rate_input.py +5 -0
- lark/types/simple_usage_based_rate_interface.py +31 -0
- lark/types/status.py +5 -0
- lark/types/subject.py +5 -0
- lark/types/subject_granting_config.py +5 -0
- lark/types/subject_granting_config_resource.py +20 -0
- lark/types/subject_resource.py +24 -0
- lark/types/subscription_resource.py +28 -0
- lark/types/sum_aggregation_pricing_metric_interface.py +22 -0
- lark/types/tiered_price.py +5 -0
- lark/types/tiered_price_wrapper.py +5 -0
- lark/types/unit.py +5 -0
- lark/types/update_pricing_plan_request.py +5 -0
- lark/types/update_rate_card_request.py +5 -0
- lark/types/update_subscription_request.py +5 -0
- lark/types/usage_based_rate.py +5 -0
- lark/types/usage_based_rate_input.py +5 -0
- lark/types/usage_unit.py +5 -0
- lark/types/validation_error.py +22 -0
- lark/types/validation_error_loc_item.py +5 -0
- lark/usage_events/__init__.py +34 -0
- lark/usage_events/client.py +293 -0
- lark/usage_events/raw_client.py +318 -0
- lark/usage_events/types/__init__.py +36 -0
- lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +5 -0
- lark/version.py +3 -0
- lark_billing-0.0.6.dist-info/METADATA +188 -0
- lark_billing-0.0.6.dist-info/RECORD +167 -0
- lark_billing-0.0.6.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
13
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
14
|
+
from ..types.create_usage_event_summary_response import CreateUsageEventSummaryResponse
|
|
15
|
+
from ..types.http_validation_error import HttpValidationError
|
|
16
|
+
from ..types.period import Period
|
|
17
|
+
from .types.create_usage_event_summary_request_aggregation_type import CreateUsageEventSummaryRequestAggregationType
|
|
18
|
+
|
|
19
|
+
# this is used as the default value for optional parameters
|
|
20
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RawUsageEventsClient:
|
|
24
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
25
|
+
self._client_wrapper = client_wrapper
|
|
26
|
+
|
|
27
|
+
def create_usage_event(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
idempotency_key: str,
|
|
31
|
+
event_name: str,
|
|
32
|
+
subject_id: str,
|
|
33
|
+
timestamp: dt.datetime,
|
|
34
|
+
data: typing.Dict[str, typing.Optional[typing.Any]],
|
|
35
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
37
|
+
"""
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
idempotency_key : str
|
|
41
|
+
|
|
42
|
+
event_name : str
|
|
43
|
+
|
|
44
|
+
subject_id : str
|
|
45
|
+
|
|
46
|
+
timestamp : dt.datetime
|
|
47
|
+
|
|
48
|
+
data : typing.Dict[str, typing.Optional[typing.Any]]
|
|
49
|
+
|
|
50
|
+
request_options : typing.Optional[RequestOptions]
|
|
51
|
+
Request-specific configuration.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
56
|
+
Successful Response
|
|
57
|
+
"""
|
|
58
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
59
|
+
"usage-events",
|
|
60
|
+
method="POST",
|
|
61
|
+
json={
|
|
62
|
+
"idempotency_key": idempotency_key,
|
|
63
|
+
"event_name": event_name,
|
|
64
|
+
"subject_id": subject_id,
|
|
65
|
+
"timestamp": timestamp,
|
|
66
|
+
"data": data,
|
|
67
|
+
},
|
|
68
|
+
headers={
|
|
69
|
+
"content-type": "application/json",
|
|
70
|
+
},
|
|
71
|
+
request_options=request_options,
|
|
72
|
+
omit=OMIT,
|
|
73
|
+
)
|
|
74
|
+
try:
|
|
75
|
+
if _response is None or not _response.text.strip():
|
|
76
|
+
return HttpResponse(response=_response, data=None)
|
|
77
|
+
if 200 <= _response.status_code < 300:
|
|
78
|
+
_data = typing.cast(
|
|
79
|
+
typing.Optional[typing.Any],
|
|
80
|
+
parse_obj_as(
|
|
81
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
82
|
+
object_=_response.json(),
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
return HttpResponse(response=_response, data=_data)
|
|
86
|
+
if _response.status_code == 422:
|
|
87
|
+
raise UnprocessableEntityError(
|
|
88
|
+
headers=dict(_response.headers),
|
|
89
|
+
body=typing.cast(
|
|
90
|
+
HttpValidationError,
|
|
91
|
+
parse_obj_as(
|
|
92
|
+
type_=HttpValidationError, # type: ignore
|
|
93
|
+
object_=_response.json(),
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
_response_json = _response.json()
|
|
98
|
+
except JSONDecodeError:
|
|
99
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
100
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
101
|
+
|
|
102
|
+
def create_usage_event_summary(
|
|
103
|
+
self,
|
|
104
|
+
*,
|
|
105
|
+
event_name: str,
|
|
106
|
+
subject_id: str,
|
|
107
|
+
period: Period,
|
|
108
|
+
aggregation_type: CreateUsageEventSummaryRequestAggregationType,
|
|
109
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
110
|
+
) -> HttpResponse[CreateUsageEventSummaryResponse]:
|
|
111
|
+
"""
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
event_name : str
|
|
115
|
+
|
|
116
|
+
subject_id : str
|
|
117
|
+
|
|
118
|
+
period : Period
|
|
119
|
+
|
|
120
|
+
aggregation_type : CreateUsageEventSummaryRequestAggregationType
|
|
121
|
+
|
|
122
|
+
request_options : typing.Optional[RequestOptions]
|
|
123
|
+
Request-specific configuration.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
HttpResponse[CreateUsageEventSummaryResponse]
|
|
128
|
+
Successful Response
|
|
129
|
+
"""
|
|
130
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
131
|
+
"usage-events/summary",
|
|
132
|
+
method="POST",
|
|
133
|
+
json={
|
|
134
|
+
"event_name": event_name,
|
|
135
|
+
"subject_id": subject_id,
|
|
136
|
+
"period": convert_and_respect_annotation_metadata(object_=period, annotation=Period, direction="write"),
|
|
137
|
+
"aggregation_type": aggregation_type,
|
|
138
|
+
},
|
|
139
|
+
headers={
|
|
140
|
+
"content-type": "application/json",
|
|
141
|
+
},
|
|
142
|
+
request_options=request_options,
|
|
143
|
+
omit=OMIT,
|
|
144
|
+
)
|
|
145
|
+
try:
|
|
146
|
+
if 200 <= _response.status_code < 300:
|
|
147
|
+
_data = typing.cast(
|
|
148
|
+
CreateUsageEventSummaryResponse,
|
|
149
|
+
parse_obj_as(
|
|
150
|
+
type_=CreateUsageEventSummaryResponse, # type: ignore
|
|
151
|
+
object_=_response.json(),
|
|
152
|
+
),
|
|
153
|
+
)
|
|
154
|
+
return HttpResponse(response=_response, data=_data)
|
|
155
|
+
if _response.status_code == 422:
|
|
156
|
+
raise UnprocessableEntityError(
|
|
157
|
+
headers=dict(_response.headers),
|
|
158
|
+
body=typing.cast(
|
|
159
|
+
HttpValidationError,
|
|
160
|
+
parse_obj_as(
|
|
161
|
+
type_=HttpValidationError, # type: ignore
|
|
162
|
+
object_=_response.json(),
|
|
163
|
+
),
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
_response_json = _response.json()
|
|
167
|
+
except JSONDecodeError:
|
|
168
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
169
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class AsyncRawUsageEventsClient:
|
|
173
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
174
|
+
self._client_wrapper = client_wrapper
|
|
175
|
+
|
|
176
|
+
async def create_usage_event(
|
|
177
|
+
self,
|
|
178
|
+
*,
|
|
179
|
+
idempotency_key: str,
|
|
180
|
+
event_name: str,
|
|
181
|
+
subject_id: str,
|
|
182
|
+
timestamp: dt.datetime,
|
|
183
|
+
data: typing.Dict[str, typing.Optional[typing.Any]],
|
|
184
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
185
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
186
|
+
"""
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
idempotency_key : str
|
|
190
|
+
|
|
191
|
+
event_name : str
|
|
192
|
+
|
|
193
|
+
subject_id : str
|
|
194
|
+
|
|
195
|
+
timestamp : dt.datetime
|
|
196
|
+
|
|
197
|
+
data : typing.Dict[str, typing.Optional[typing.Any]]
|
|
198
|
+
|
|
199
|
+
request_options : typing.Optional[RequestOptions]
|
|
200
|
+
Request-specific configuration.
|
|
201
|
+
|
|
202
|
+
Returns
|
|
203
|
+
-------
|
|
204
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
205
|
+
Successful Response
|
|
206
|
+
"""
|
|
207
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
208
|
+
"usage-events",
|
|
209
|
+
method="POST",
|
|
210
|
+
json={
|
|
211
|
+
"idempotency_key": idempotency_key,
|
|
212
|
+
"event_name": event_name,
|
|
213
|
+
"subject_id": subject_id,
|
|
214
|
+
"timestamp": timestamp,
|
|
215
|
+
"data": data,
|
|
216
|
+
},
|
|
217
|
+
headers={
|
|
218
|
+
"content-type": "application/json",
|
|
219
|
+
},
|
|
220
|
+
request_options=request_options,
|
|
221
|
+
omit=OMIT,
|
|
222
|
+
)
|
|
223
|
+
try:
|
|
224
|
+
if _response is None or not _response.text.strip():
|
|
225
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
226
|
+
if 200 <= _response.status_code < 300:
|
|
227
|
+
_data = typing.cast(
|
|
228
|
+
typing.Optional[typing.Any],
|
|
229
|
+
parse_obj_as(
|
|
230
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
231
|
+
object_=_response.json(),
|
|
232
|
+
),
|
|
233
|
+
)
|
|
234
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
235
|
+
if _response.status_code == 422:
|
|
236
|
+
raise UnprocessableEntityError(
|
|
237
|
+
headers=dict(_response.headers),
|
|
238
|
+
body=typing.cast(
|
|
239
|
+
HttpValidationError,
|
|
240
|
+
parse_obj_as(
|
|
241
|
+
type_=HttpValidationError, # type: ignore
|
|
242
|
+
object_=_response.json(),
|
|
243
|
+
),
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
_response_json = _response.json()
|
|
247
|
+
except JSONDecodeError:
|
|
248
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
249
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
250
|
+
|
|
251
|
+
async def create_usage_event_summary(
|
|
252
|
+
self,
|
|
253
|
+
*,
|
|
254
|
+
event_name: str,
|
|
255
|
+
subject_id: str,
|
|
256
|
+
period: Period,
|
|
257
|
+
aggregation_type: CreateUsageEventSummaryRequestAggregationType,
|
|
258
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
259
|
+
) -> AsyncHttpResponse[CreateUsageEventSummaryResponse]:
|
|
260
|
+
"""
|
|
261
|
+
Parameters
|
|
262
|
+
----------
|
|
263
|
+
event_name : str
|
|
264
|
+
|
|
265
|
+
subject_id : str
|
|
266
|
+
|
|
267
|
+
period : Period
|
|
268
|
+
|
|
269
|
+
aggregation_type : CreateUsageEventSummaryRequestAggregationType
|
|
270
|
+
|
|
271
|
+
request_options : typing.Optional[RequestOptions]
|
|
272
|
+
Request-specific configuration.
|
|
273
|
+
|
|
274
|
+
Returns
|
|
275
|
+
-------
|
|
276
|
+
AsyncHttpResponse[CreateUsageEventSummaryResponse]
|
|
277
|
+
Successful Response
|
|
278
|
+
"""
|
|
279
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
280
|
+
"usage-events/summary",
|
|
281
|
+
method="POST",
|
|
282
|
+
json={
|
|
283
|
+
"event_name": event_name,
|
|
284
|
+
"subject_id": subject_id,
|
|
285
|
+
"period": convert_and_respect_annotation_metadata(object_=period, annotation=Period, direction="write"),
|
|
286
|
+
"aggregation_type": aggregation_type,
|
|
287
|
+
},
|
|
288
|
+
headers={
|
|
289
|
+
"content-type": "application/json",
|
|
290
|
+
},
|
|
291
|
+
request_options=request_options,
|
|
292
|
+
omit=OMIT,
|
|
293
|
+
)
|
|
294
|
+
try:
|
|
295
|
+
if 200 <= _response.status_code < 300:
|
|
296
|
+
_data = typing.cast(
|
|
297
|
+
CreateUsageEventSummaryResponse,
|
|
298
|
+
parse_obj_as(
|
|
299
|
+
type_=CreateUsageEventSummaryResponse, # type: ignore
|
|
300
|
+
object_=_response.json(),
|
|
301
|
+
),
|
|
302
|
+
)
|
|
303
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
304
|
+
if _response.status_code == 422:
|
|
305
|
+
raise UnprocessableEntityError(
|
|
306
|
+
headers=dict(_response.headers),
|
|
307
|
+
body=typing.cast(
|
|
308
|
+
HttpValidationError,
|
|
309
|
+
parse_obj_as(
|
|
310
|
+
type_=HttpValidationError, # type: ignore
|
|
311
|
+
object_=_response.json(),
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
)
|
|
315
|
+
_response_json = _response.json()
|
|
316
|
+
except JSONDecodeError:
|
|
317
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
318
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .create_usage_event_summary_request_aggregation_type import CreateUsageEventSummaryRequestAggregationType
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {
|
|
11
|
+
"CreateUsageEventSummaryRequestAggregationType": ".create_usage_event_summary_request_aggregation_type"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
16
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
17
|
+
if module_name is None:
|
|
18
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
19
|
+
try:
|
|
20
|
+
module = import_module(module_name, __package__)
|
|
21
|
+
if module_name == f".{attr_name}":
|
|
22
|
+
return module
|
|
23
|
+
else:
|
|
24
|
+
return getattr(module, attr_name)
|
|
25
|
+
except ImportError as e:
|
|
26
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
27
|
+
except AttributeError as e:
|
|
28
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def __dir__():
|
|
32
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
33
|
+
return sorted(lazy_attrs)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
__all__ = ["CreateUsageEventSummaryRequestAggregationType"]
|
lark/version.py
ADDED
|
@@ -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
|
+
|